/*
 * ScrumprojektView.java
 */
package scrumprojekt;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.MessagingException;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.Image;
import java.util.GregorianCalendar;

import java.io.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

/**
 * The application's main frame.
 */
public class ScrumprojektView extends FrameView {

    public ScrumprojektView(SingleFrameApplication app) {
        super(app);


        try {
            db = new dbklass();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error", "Error!", JOptionPane.ERROR_MESSAGE);
        }
        initComponents();
        
        doljKomponenterLogin();

        jlRapport = new DefaultListModel();
        jlRapport2 = new DefaultListModel();
        jlRapport3 = new DefaultListModel();
        jlRaRapporter1 = new DefaultListModel();
        jlReseorderrapport = new DefaultListModel();
        jlRapportStatus = new DefaultListModel();
        jlRapportStatusOk = new DefaultListModel();
        jlRReseorderStatus = new DefaultListModel();
        jlRForskottStatus = new DefaultListModel();
        jlRReseorderStatusOk = new DefaultListModel();
        jlForskottStatusOk = new DefaultListModel();
        
        jlEjGodRapportModel = new DefaultListModel();
        jlEjGodReseorderModel = new DefaultListModel();
        jlEjGodForskottModel = new DefaultListModel();
        jListTest = new DefaultListModel();
        jListTest3 = new DefaultListModel();
        
        fyllAnsokCb();
        fyllUppdragCb();
        fyllAnvkontoCb();
        fyllIckeAnvkontoCb();
        fyllRapAnstalld();


        popupLaggTillUppdrag.setLocationRelativeTo(null);
        popupLaggTillLand.setLocationRelativeTo(null);
        
        jRadioManad.setSelected(true);
        rbRPrivatbil.setSelected(true);
        tfRKM.setEditable(true);
        btnRSpara.setVisible(false);
        lblInloggad.setVisible(false);
        rapportTfCount.setVisible(false);
       
              


        setRapportCount();
        setAnvKontonCount();

        
        reseorder();
        settDatum();
        
        lblAnstid.setVisible(false);
        lblLogin.setVisible(false);

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }
    
    public void InloggadJustNu(){
        
    int id = Integer.parseInt(lblAnstid.getText());
    
    ArrayList<Anstalld> anstallda = new ArrayList<Anstalld>();
    
    try {
            ArrayList<HashMap<String, String>> anvandare = db.fetchRows("select * from anstalld where losenord like '%'");

            for (HashMap<String, String> anv : anvandare) {


                Anstalld anstalld = new Anstalld(
                        anv.get("fornamn"),
                        anv.get("efternamn"),
                        Integer.parseInt(anv.get("personnummer")),
                        anv.get("mail"),
                        Integer.parseInt(anv.get("telefon")),
                        anv.get("adress"),
                        anv.get("losenord"),
                        Integer.parseInt(anv.get("behorighet")),
                        Integer.parseInt(anv.get("anstalldid")));

                anstallda.add(anstalld);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    
        for(int i=0; i < anstallda.size(); i++){
            Anstalld anst = anstallda.get(i);
            if(anst.getAnstalldid() == id){
            lblKent.setText(anst.getFornamn()+" "+anst.getEfternamn());
            }
        }
        
        lblInloggad.setVisible(true);
    
    
    }

    public void settDatum() {

        GregorianCalendar cal = new GregorianCalendar();

        String date = "0000-00-00";

        int year = cal.get(GregorianCalendar.YEAR);
        int month = cal.get(GregorianCalendar.MONTH) + 1;
        int day = cal.get(GregorianCalendar.DAY_OF_MONTH);

        String mont = Integer.toString(month);

        if (month < 10) {
            mont = "0" + month;
        }

        date = year + "-" + mont + "-" + day;

        lblRapDatum.setText(date);

    }

    //   public void valjaRapportDatum(){
    //Fyller i de valda datumen i textarean
//        taSkapaRapport.setText(taSkapaRapport.getText() + "Startdatum : " +  dCCRapportStart.getText() +"\n");
    //      taSkapaRapport.setText(taSkapaRapport.getText() + "Slutdatum  : " +dCCRapportSlut.getText() +"\n");
    //  }
    public void fyllRapAnstalld() {
        try {
            ArrayList<HashMap<String, String>> anvandare = db.fetchRows("select * from anstalld");

            for (HashMap<String, String> anv : anvandare) {


                Anstalld anstalld = new Anstalld(
                        anv.get("fornamn"),
                        anv.get("efternamn"),
                        Integer.parseInt(anv.get("personnummer")),
                        anv.get("mail"),
                        Integer.parseInt(anv.get("telefon")),
                        anv.get("adress"),
                        anv.get("losenord"),
                        Integer.parseInt(anv.get("behorighet")),
                        Integer.parseInt(anv.get("anstalldid")));

                cbRaAnstalld.addItem(anstalld);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    public void fyllAnvkontoCb() {
        try {
            ArrayList<HashMap<String, String>> anvandare = db.fetchRows("select * from anstalld where losenord like '%'");

            for (HashMap<String, String> anv : anvandare) {


                Anstalld anstalld = new Anstalld(
                        anv.get("fornamn"),
                        anv.get("efternamn"),
                        Integer.parseInt(anv.get("personnummer")),
                        anv.get("mail"),
                        Integer.parseInt(anv.get("telefon")),
                        anv.get("adress"),
                        anv.get("losenord"),
                        Integer.parseInt(anv.get("behorighet")),
                        Integer.parseInt(anv.get("anstalldid")));

                cbAkonto.addItem(anstalld);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    public void fyllCbEdit() {

        ArrayList<HashMap<String, String>> rapporter = new ArrayList<HashMap<String, String>>();
        String query = "select rapportid, anstalldid, summainklmoms, summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum, extrakostnader, kommentar from rapport";

        try {
            rapporter = db.fetchRows(query);

            for (HashMap<String, String> rapport : rapporter) {

                Rapport rap = new Rapport(rapport.get("startdatum"), rapport.get("slutdatum"), Integer.parseInt(rapport.get("summainklmoms")), Integer.parseInt(rapport.get("summaexklmoms")),
                        rapport.get("kvitto"), rapport.get("godkand"), rapport.get("godkandav"), Integer.parseInt(rapport.get("rapportid")), 0, Integer.parseInt(rapport.get("anstalldid")), Integer.parseInt(rapport.get("extrakostnader")), rapport.get("kommentar"));
           
               int id = rap.getAnstalldId();
               int id2 = Integer.parseInt(lblAnstid.getText());
               String godkand = rap.getGodkand();
                
               if(id == id2 && (godkand.equals("Nej") || godkand.equals("ccc"))) {
                cbRapportEdit.addItem(rap);
               }

            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    public void fyllIckeAnvkontoCb() {
        try {
            ArrayList<HashMap<String, String>> anvandare = db.fetchRows("select * from anstalld where losenord is null");

            for (HashMap<String, String> anv : anvandare) {


                Anstalld anstalld = new Anstalld(
                        anv.get("fornamn"),
                        anv.get("efternamn"),
                        Integer.parseInt(anv.get("personnummer")),
                        "",
                        Integer.parseInt(anv.get("telefon")),
                        anv.get("adress"),
                        anv.get("losenord"),
                        Integer.parseInt(anv.get("behorighet")),
                        Integer.parseInt(anv.get("anstalldid")));

                cbAIKonto.addItem(anstalld);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    public void fyllUppdragCb() {
        try {
            ArrayList<HashMap<String, String>> uppdragsnamn = db.fetchRows("select * from konto");

            for (HashMap<String, String> uppdrag : uppdragsnamn) {

                Konto uppdraget = new Konto(Integer.parseInt(uppdrag.get("kontonr")), uppdrag.get("uppdragsnamn"));

                cbPopUpKonto.addItem(uppdraget);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    public void setAnvKontonCount() {

        int count = 0;

        try {
            ArrayList<String> lista = new ArrayList<String>();
            lista = db.fetchColumn("SELECT anstalldid FROM anstalld");
            count = lista.size() + 1;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }


        tfAid.setText(Integer.toString(count));
    }

    public void setRapportCount() {

        int count = 0;

        try {
            ArrayList<String> lista = new ArrayList<String>();
            lista = db.fetchColumn("SELECT rapportid FROM rapport");
            count = lista.size() + 1;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }


        rapportTfCount.setText(Integer.toString(count));
    }

    public void doljFalt() {
        tfRKM.setEditable(false);
        tfRInkl.setEditable(false);
        tfRExkl.setEditable(false);
        tfROvrigt.setEditable(false);
    }

    public void sparaPdfSummeringKvartal(String anstId, String manad1, String manad2, String manad3) {


        int summainklmomsTotal = 0;
        int summaexklmomsTotal = 0;

        int summainklmomsOvrigt = 0;
        double summaexklmomsOvrigt = 0;

        int totinkl = 0;
        double totexkl = 0;



        int antalRapporter = 0;


        String name = cbRaAnstalld.getSelectedItem().toString();

        String inloggad = lblAnstid.getText();

        ArrayList<ArrayList<String>> rapporterdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> landerdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> fardsattdb = new ArrayList<ArrayList<String>>();

        String queryRapport = "select rapportid, summainklmoms, "
                + "summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum, extrakostnader "
                + "from rapport where anstalldid = '" + anstId + "' and startdatum like '" + manad1 + "%' or startdatum like '" + manad2 + "%' or startdatum like '" + manad3 + "%'";



        try {

            rapporterdb = db.fetchMatrix(queryRapport);
            for (ArrayList<String> rapportern : rapporterdb) {

                summainklmomsTotal = summainklmomsTotal + Integer.parseInt(rapportern.get(1));
                summaexklmomsTotal = summaexklmomsTotal + Integer.parseInt(rapportern.get(2));
                summainklmomsOvrigt = summainklmomsOvrigt + Integer.parseInt(rapportern.get(8));
                summaexklmomsOvrigt = summaexklmomsOvrigt + (Integer.parseInt(rapportern.get(8)) * 0.8);
                antalRapporter = antalRapporter + 1;
            }

            totinkl = summainklmomsTotal + summainklmomsOvrigt;
            totexkl = summaexklmomsTotal + summaexklmomsOvrigt;
            /*
             * här skapas ett pdf dokument med information från db
             * den har information från rapport tabellen genom att varibler blirvit tilldelad rätt värde
             * Det finns en for loop som skriver ut alla länder som finns för rapporten
             * Det finns en for loop som skriver ut alla konton som finns för rapporten
             * Det finns en for loop som skriver ut alla färdsätt som finns för rapporten
             */
            try {
                Document document = new Document();
                PdfWriter.getInstance(document, new FileOutputStream(inloggad + ".pdf"));
                document.open();


                String hittaLoga = "http://kmdev.se/vitsutbildning.png";
                Image imageLogo = Image.getInstance(hittaLoga);
                imageLogo.setAlignment(Image.ALIGN_MIDDLE);
                document.add(imageLogo);

                document.add(new Paragraph("OBS. Detta är en sammanställd rapport"));
                document.add(new Paragraph("Gällandes: " + name));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Sumeringen gäller " + antalRapporter + "st rapporter och under det senaste kvartalet"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summainklmomsTotal + " SEK inkl. moms"));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summaexklmomsTotal + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa övriga kostnader: " + summainklmomsOvrigt + " SEK inkl. moms"));
                document.add(new Paragraph("Summa övriga kostnader: " + summaexklmomsOvrigt + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Total summa: " + totinkl + " SEK inkl. moms"));
                document.add(new Paragraph("Total summa: " + totexkl + " SEK exkl. moms"));
                document.add(new Paragraph(" "));


                document.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Ett fel upppstod när pdf skulle skapas");
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av rapport!");
        } finally {
            oppnaPdf(inloggad);
        }
    }

    public void sparaPdfSummeringAr(String anstId, String startDate) {


        int summainklmomsTotal = 0;
        int summaexklmomsTotal = 0;

        int summainklmomsOvrigt = 0;
        double summaexklmomsOvrigt = 0;

        int totinkl = 0;
        double totexkl = 0;



        int antalRapporter = 0;


        String name = cbRaAnstalld.getSelectedItem().toString();

        String inloggad = lblAnstid.getText();

        ArrayList<ArrayList<String>> rapporterdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> landerdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> fardsattdb = new ArrayList<ArrayList<String>>();

        String queryRapport = "select rapportid, summainklmoms, "
                + "summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum, extrakostnader "
                + "from rapport where anstalldid = '" + anstId + "' and startdatum like '" + startDate + "%'";



        try {

            rapporterdb = db.fetchMatrix(queryRapport);
            for (ArrayList<String> rapportern : rapporterdb) {

                summainklmomsTotal = summainklmomsTotal + Integer.parseInt(rapportern.get(1));
                summaexklmomsTotal = summaexklmomsTotal + Integer.parseInt(rapportern.get(2));
                summainklmomsOvrigt = summainklmomsOvrigt + Integer.parseInt(rapportern.get(8));
                summaexklmomsOvrigt = summaexklmomsOvrigt + (Integer.parseInt(rapportern.get(8)) * 0.8);
                antalRapporter = antalRapporter + 1;
            }

            totinkl = summainklmomsTotal + summainklmomsOvrigt;
            totexkl = summaexklmomsTotal + summaexklmomsOvrigt;
            /*
             * här skapas ett pdf dokument med information från db
             * den har information från rapport tabellen genom att varibler blirvit tilldelad rätt värde
             * Det finns en for loop som skriver ut alla länder som finns för rapporten
             * Det finns en for loop som skriver ut alla konton som finns för rapporten
             * Det finns en for loop som skriver ut alla färdsätt som finns för rapporten
             */
            try {
                Document document = new Document();
                PdfWriter.getInstance(document, new FileOutputStream(inloggad + ".pdf"));
                document.open();


                String hittaLoga = "http://kmdev.se/vitsutbildning.png";
                Image imageLogo = Image.getInstance(hittaLoga);
                imageLogo.setAlignment(Image.ALIGN_MIDDLE);
                document.add(imageLogo);

                document.add(new Paragraph("OBS. Detta är en sammanställd rapport"));
                document.add(new Paragraph("Gällandes: " + name));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Sumeringen gäller " + antalRapporter + "st rapporter och under ett års tid"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summainklmomsTotal + " SEK inkl. moms"));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summaexklmomsTotal + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa övriga kostnader: " + summainklmomsOvrigt + " SEK inkl. moms"));
                document.add(new Paragraph("Summa övriga kostnader: " + summaexklmomsOvrigt + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Total summa: " + totinkl + " SEK inkl. moms"));
                document.add(new Paragraph("Total summa: " + totexkl + " SEK exkl. moms"));
                document.add(new Paragraph(" "));


                document.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Ett fel upppstod när pdf skulle skapas");
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av rapport!");
        } finally {
            oppnaPdf(inloggad);
        }
    }

    public void sparaPdfSummeringManad(String anstId, String startDate) {


        int summainklmomsTotal = 0;
        int summaexklmomsTotal = 0;

        int summainklmomsOvrigt = 0;
        double summaexklmomsOvrigt = 0;

        int totinkl = 0;
        double totexkl = 0;



        int antalRapporter = 0;


        String name = cbRaAnstalld.getSelectedItem().toString();

        String inloggad = lblAnstid.getText();

        ArrayList<ArrayList<String>> rapporterdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> landerdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> fardsattdb = new ArrayList<ArrayList<String>>();

        String queryRapport = "select rapportid, summainklmoms, "
                + "summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum, extrakostnader "
                + "from rapport where anstalldid = '" + anstId + "' and startdatum like '" + startDate + "%'";



        try {

            rapporterdb = db.fetchMatrix(queryRapport);
            for (ArrayList<String> rapportern : rapporterdb) {

                summainklmomsTotal = summainklmomsTotal + Integer.parseInt(rapportern.get(1));
                summaexklmomsTotal = summaexklmomsTotal + Integer.parseInt(rapportern.get(2));
                summainklmomsOvrigt = summainklmomsOvrigt + Integer.parseInt(rapportern.get(8));
                summaexklmomsOvrigt = summaexklmomsOvrigt + (Integer.parseInt(rapportern.get(8)) * 0.8);
                antalRapporter = antalRapporter + 1;
            }

            totinkl = summainklmomsTotal + summainklmomsOvrigt;
            totexkl = summaexklmomsTotal + summaexklmomsOvrigt;
            /*
             * här skapas ett pdf dokument med information från db
             * den har information från rapport tabellen genom att varibler blirvit tilldelad rätt värde
             * Det finns en for loop som skriver ut alla länder som finns för rapporten
             * Det finns en for loop som skriver ut alla konton som finns för rapporten
             * Det finns en for loop som skriver ut alla färdsätt som finns för rapporten
             */
            try {
                Document document = new Document();
                PdfWriter.getInstance(document, new FileOutputStream(inloggad + ".pdf"));
                document.open();


                String hittaLoga = "http://kmdev.se/vitsutbildning.png";
                Image imageLogo = Image.getInstance(hittaLoga);
                imageLogo.setAlignment(Image.ALIGN_MIDDLE);
                document.add(imageLogo);

                document.add(new Paragraph("OBS. Detta är en sammanställd rapport"));
                document.add(new Paragraph("Gällandes: " + name));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Sumeringen gäller " + antalRapporter + "st rapporter och under en månads tid"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summainklmomsTotal + " SEK inkl. moms"));
                document.add(new Paragraph("Summa färdkostnader och traktamente: " + summaexklmomsTotal + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Summa övriga kostnader: " + summainklmomsOvrigt + " SEK inkl. moms"));
                document.add(new Paragraph("Summa övriga kostnader: " + summaexklmomsOvrigt + " SEK exkl. moms"));
                document.add(new Paragraph(" "));
                document.add(new Paragraph("Total summa: " + totinkl + " SEK inkl. moms"));
                document.add(new Paragraph("Total summa: " + totexkl + " SEK exkl. moms"));
                document.add(new Paragraph(" "));


                document.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Ett fel upppstod när pdf skulle skapas");
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av rapport!");
        } finally {
            oppnaPdf(inloggad);
        }
    }

    public void sparaPdf(String anstId, String startDat) {

        String rapportid = "";
        String startdatum = "";
        String slutdatum = "";
        String summainklmoms = "";
        String summaexklmoms = "";
        String kvitto = "";
        String godkand = "";
        String godkandav = "";

        String inloggad = lblAnstid.getText();

        ArrayList<ArrayList<String>> rapporterdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> landerdb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> kontondb = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> fardsattdb = new ArrayList<ArrayList<String>>();

        String queryRapport = "select rapportid, summainklmoms, "
                + "summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum "
                + "from rapport where anstalldid = '" + anstId + "' and startdatum = '" + startDat + "'";

        try {
            rapporterdb = db.fetchMatrix(queryRapport);

            for (ArrayList<String> rapportern : rapporterdb) {
                rapportid = rapportern.get(0);
                summainklmoms = rapportern.get(1);
                summaexklmoms = rapportern.get(2);
                kvitto = rapportern.get(3);
                godkand = rapportern.get(4);
                godkandav = rapportern.get(5);
                startdatum = rapportern.get(6);
                slutdatum = rapportern.get(7);

                String queryLand = "Select land.landnamn, rapportland.landstart, rapportland.landslut, "
                        + "rapportland.landdagar, rapportland.rapportlandtraktamente from "
                        + "(land join rapportland on land.landid = rapportland.landid) "
                        + "where rapportland.rapportid = " + rapportid;

                String queryKonto = "Select konto.kontonr, konto.uppdragsnamn, kontorapport.andel "
                        + "from (konto join kontorapport on konto.kontonr = kontorapport.kontonr) "
                        + "where kontorapport.rapportid = " + rapportid;


                String queryFardsatt = "Select fardsatt.typ, fardrapport.summainklmoms, fardrapport.summaexklmoms "
                        + "from (fardsatt join fardrapport on fardsatt.fardsattid = fardrapport.fardsattid) "
                        + "where fardrapport.rapportid = " + rapportid;
                /*
                 * fyller ArrayList<ArrayList<String>> land från db genom att använda queryLand.
                 * 0 = land.landnamn
                 * 1 = rapportland.landstart
                 * 2 = rapportland.landslut
                 * 3 = rapportland.landdagar
                 * 4 = rapportland.traktamente
                 */
                try {
                    landerdb = db.fetchMatrix(queryLand);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av land");
                }

                /*
                 * fyller ArrayList<ArrayList<String>> konto från db genom att använda queryKonto.
                 * 0 = konto.kontonr
                 * 1 = konto.uppdragsnamn
                 * 2 = kontorapport.andel
                 */
                try {
                    kontondb = db.fetchMatrix(queryKonto);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av konto");
                }

                /*
                 * fyller ArrayList<ArrayList<String>> fardsattdb från db genom att använda queryFardsatt.
                 * 0 = fardsatt.typ
                 * 1 = fardraport.summainklmoms
                 * 2 = fardraport.summaexklmoms
                 */
                try {
                    fardsattdb = db.fetchMatrix(queryFardsatt);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av färdsätt");
                }

                /*
                 * här skapas ett pdf dokument med information från db
                 * den har information från rapport tabellen genom att varibler blirvit tilldelad rätt värde
                 * Det finns en for loop som skriver ut alla länder som finns för rapporten
                 * Det finns en for loop som skriver ut alla konton som finns för rapporten
                 * Det finns en for loop som skriver ut alla färdsätt som finns för rapporten
                 */
                try {
                    Document document = new Document();
                    PdfWriter.getInstance(document, new FileOutputStream(inloggad + ".pdf"));
                    document.open();


                    String hittaLoga = "http://kmdev.se/vitsutbildning.png";
                    Image imageLogo = Image.getInstance(hittaLoga);
                    imageLogo.setAlignment(Image.ALIGN_MIDDLE);
                    document.add(imageLogo);

                    document.add(new Paragraph("RapportID : " + rapportid));

                    for (ArrayList<String> konton : kontondb) {
                        document.add(new Paragraph("Konto nummer : " + konton.get(0)));
                        document.add(new Paragraph("Uppdragets namn : " + konton.get(1)));
                        document.add(new Paragraph("Andel : " + konton.get(2) + " %"));
                    }

                    document.add(new Paragraph("Datum för start : " + startdatum));
                    document.add(new Paragraph("Datum för slut : " + slutdatum));
                    document.add(new Paragraph("Summa inklusive moms : " + summainklmoms));
                    document.add(new Paragraph("Summa exklusive moms : " + summaexklmoms));
                    document.add(new Paragraph("Finns kvitto? " + kvitto));
                    document.add(new Paragraph(""));
                    if (godkand.equals("Ja")) {
                        document.add(new Paragraph("Rapporten har blivit godkänd"));
                        document.add(new Paragraph("Rapporten är godkänd av:" + godkandav));
                    }
                    document.add(new Paragraph(" "));
                    for (ArrayList<String> land : landerdb) {
                        document.add(new Paragraph("Landets namn : " + land.get(0)));
                        document.add(new Paragraph("Datum för start i land : " + land.get(1)));
                        document.add(new Paragraph("Datum för slut i land : " + land.get(2)));
                        document.add(new Paragraph("Antal dagar i land : " + land.get(3)));
                        document.add(new Paragraph("Summa för traktamente i land : " + land.get(4)));
                    }
                    document.add(new Paragraph(" "));
                    for (ArrayList<String> fardsatt : fardsattdb) {
                        document.add(new Paragraph("Sort utav färdsätt : " + fardsatt.get(0)));
                        document.add(new Paragraph("Summa inklusive moms för färdsättet : " + fardsatt.get(1)));
                        document.add(new Paragraph("Summa exklusive moms för färdsättet : " + fardsatt.get(2)));
                        document.add(new Paragraph(" "));
                    }
                    document.close();
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Ett fel upppstod när pdf skulle skapas");
                }
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ett fel upppstod med hämtning av rapport!");
        } finally {
            oppnaPdf(inloggad);
        }
    }

    public void oppnaPdf(String rapportNamn) {
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + rapportNamn + ".pdf");
        } catch (Exception e) {
        }
    }

    public void raderaPdf() {
        File f = new File(taRKommentar.getText() + ".pdf");
        if (f.exists() && f.isFile()) {
            f.delete();
        }
    }

    public void fyllRapportStatus() {
        jlRStatus.setModel(jlRapportStatus);
        jlRapportStatus.clear();

        try {
            ArrayList<HashMap<String, String>> anstRapport = db.fetchRows("select * from rapport where anstalldid = " + lblAnstid.getText()
                    + " and godkand = 'Ja'");

            for (HashMap<String, String> rapport : anstRapport) {

                Rapport rap = new Rapport(rapport.get("startdatum"), rapport.get("slutdatum"), Integer.parseInt(rapport.get("summainklmoms")), Integer.parseInt(rapport.get("summaexklmoms")),
                        rapport.get("kvitto"), rapport.get("godkand"), rapport.get("godkandav"),
                        Integer.parseInt(rapport.get("rapportid")), 0, Integer.parseInt(rapport.get("anstalldid")),
                        Integer.parseInt(rapport.get("extrakostnader")), rapport.get("kommentar"));

                jlRapportStatus.addElement(rap);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när godkända rapporter skulle hämtas!");
        } finally {
            if (jlRapportStatus.isEmpty()) {
                jBOk.setEnabled(false);
            } else {
                jBOk.setEnabled(true);
            }
        }
    }

    public void fyllRapportStatusOk() {
        jlRStatusOk.setModel(jlRapportStatusOk);
        jlRapportStatusOk.clear();

        try {
            ArrayList<HashMap<String, String>> anstRapportOk = db.fetchRows("select * from rapport where anstalldid = " + lblAnstid.getText()
                    + " and godkand = 'Ok'");

            for (HashMap<String, String> rapport : anstRapportOk) {
                Rapport rapOk = new Rapport(rapport.get("startdatum"), rapport.get("slutdatum"), Integer.parseInt(rapport.get("summainklmoms")), Integer.parseInt(rapport.get("summaexklmoms")),
                        rapport.get("kvitto"), rapport.get("godkand"), rapport.get("godkandav"),
                        Integer.parseInt(rapport.get("rapportid")), 0, Integer.parseInt(rapport.get("anstalldid")),
                        Integer.parseInt(rapport.get("extrakostnader")), rapport.get("kommentar"));

                jlRapportStatusOk.addElement(rapOk);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när lästa rapporter skulle hämtas!");
        }
    }

    private void fyllForskottStatus() {
        jlRForskott.setModel(jlRForskottStatus);
        jlRForskottStatus.clear();

        try {
            ArrayList<HashMap<String, String>> forskott = db.fetchRows("select * from forskott where anstalldid = " + lblAnstid.getText()+" and godkand = 'Ja'");

            for (HashMap<String, String> skott : forskott) {
                Forskott fsk = new Forskott(Integer.parseInt(skott.get("forskottid")),
                        Integer.parseInt(skott.get("forskottsumma")),
                        Integer.parseInt(skott.get("kontonr")),
                        Integer.parseInt(skott.get("anstalldid")),
                        skott.get("godkand"),
                        skott.get("kommentar"));

                jlRForskottStatus.addElement(fsk);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när godkända rapporter skulle hämtas!");
        }
    }
    
    private void fyllForskottStatusOk() {
        jlRForskottOk.setModel(jlForskottStatusOk);
        jlForskottStatusOk.clear();

        try {
            ArrayList<HashMap<String, String>> forskott = db.fetchRows("select * from forskott where anstalldid = "
                    + lblAnstid.getText() + " and godkand = 'Ok'");

            for (HashMap<String, String> skott : forskott) {
                Forskott fsk = new Forskott(Integer.parseInt(skott.get("forskottid")),
                        Integer.parseInt(skott.get("forskottsumma")),
                        Integer.parseInt(skott.get("kontonr")),
                        Integer.parseInt(skott.get("anstalldid")),
                        skott.get("godkand"),
                        skott.get("kommentar"));

                jlForskottStatusOk.addElement(fsk);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när godkända rapporter skulle hämtas!");
        }
    }

    private void fyllReseorderStatus() {
        jlRReseorder.setModel(jlRReseorderStatus);
        jlRReseorderStatus.clear();

        try {
            ArrayList<HashMap<String, String>> reseorder = db.fetchRows("select * from reseorder where anstalldid = "
                    + lblAnstid.getText() + " and godkand = 'Ja'");

            for (HashMap<String, String> order : reseorder) {
                Reseorder res = new Reseorder(Integer.parseInt(order.get("orderid")),
                        Integer.parseInt(order.get("anstalldid")),
                        order.get("land"),
                        order.get("datumstart"),
                        order.get("datumslut"),
                        order.get("konto"),
                        order.get("godkand"),
                        order.get("kommentar")
                        );

                jlRReseorderStatus.addElement(res);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när godkända rapporter skulle hämtas!");
        }
    }

    private void fyllReseorderStatusOk() {
        jlRReseorderOk.setModel(jlRReseorderStatusOk);
        jlRReseorderStatusOk.clear();

        try {
            ArrayList<HashMap<String, String>> reseorder = db.fetchRows("select * from reseorder where anstalldid = "
                    + lblAnstid.getText() + " and godkand = 'Ok'");

            for (HashMap<String, String> order : reseorder) {
                Reseorder res = new Reseorder(Integer.parseInt(order.get("orderid")),
                        Integer.parseInt(order.get("anstalldid")),
                        order.get("land"),
                        order.get("datumstart"),
                        order.get("datumslut"),
                        order.get("konto"),
                        order.get("godkand"),
                        order.get("kommentar"));

                jlRReseorderStatusOk.addElement(res);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nånting gick fel när godkända rapporter skulle hämtas!");
        }
    }
    
    public void kollaRapport() {
        int rapportensid = jlRStatus.getSelectedIndex();
        Rapport rap = (Rapport) jlRapportStatus.getElementAt(rapportensid);
        int rapportid = rap.getRapportid();

        if (rapportensid > -1) {
            try {
                db.update("Update rapport set godkand = 'Ok' where rapportid = " + rapportid);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "nånting gick fel");
            } finally {
                fyllRapportStatus();
                fyllRapportStatusOk();
            }
        } else {
            JOptionPane.showMessageDialog(null, "Du måste välja en rapport!");
        }
    }
    
    public void kollaReseorder() {
        int ordernsid = jlRReseorder.getSelectedIndex();
        Reseorder rap = (Reseorder) jlRReseorderStatus.getElementAt(ordernsid);
        int orderid = rap.getOrderid();

        if (orderid > -1) {
            try {
                db.update("Update reseorder set godkand = 'Ok' where orderid = " + orderid);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "nånting gick fel");
            } finally {
                fyllReseorderStatus();
                fyllReseorderStatusOk();
            }
        } else {
            JOptionPane.showMessageDialog(null, "Du måste välja en reseorder!");
        }
    }
    
    public void kollaForskott() {
        int forskottensid = jlRForskott.getSelectedIndex();
        Forskott rap = (Forskott) jlRForskottStatus.getElementAt(forskottensid);
        int forskott = rap.getForskottId();

        if (forskottensid > -1) {
            try {
                db.update("Update forskott set godkand = 'Ok' where forskottid = " + forskott);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "nånting gick fel");
            } finally {
                fyllForskottStatus();
                fyllForskottStatusOk();
            }
        } else {
            JOptionPane.showMessageDialog(null, "Du måste välja ett förskott!");
        }
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ScrumprojektApp.getApplication().getMainFrame();
            aboutBox = new ScrumprojektAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ScrumprojektApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        tfRInkl = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        tfRExkl = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        tfROvrigt = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tfRKM = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        taRKommentar = new javax.swing.JTextArea();
        jLabel11 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cbRapportEdit = new javax.swing.JComboBox();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        btnRapportLaggTillKonto = new javax.swing.JButton();
        btnRapportLaggTillLand = new javax.swing.JButton();
        dCCRapportStart = new datechooser.beans.DateChooserCombo();
        dCCRapportSlut = new datechooser.beans.DateChooserCombo();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlSkapaRapport = new javax.swing.JList();
        rbROvriga = new javax.swing.JRadioButton();
        rbRPrivatbil = new javax.swing.JRadioButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jlRUppdrag = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        jlRFardsatt = new javax.swing.JList();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        btnRLaggTillFardsatt = new javax.swing.JButton();
        rapportTfCount = new javax.swing.JTextField();
        lblAnstid = new javax.swing.JLabel();
        lblLogin = new javax.swing.JLabel();
        btnRSpara = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        cbRaAnstalld = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jlRaRapporter = new javax.swing.JList();
        jLabel8 = new javax.swing.JLabel();
        jButton9 = new javax.swing.JButton();
        jSeparator8 = new javax.swing.JSeparator();
        jSeparator9 = new javax.swing.JSeparator();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jRadioManad = new javax.swing.JRadioButton();
        jRadioKvartal = new javax.swing.JRadioButton();
        jRadioAr = new javax.swing.JRadioButton();
        jButton17 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        lblRapDatum = new javax.swing.JLabel();
        jButton18 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        tfANamn = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        tfAKonto = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jButton11 = new javax.swing.JButton();
        cbAkonto = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel31 = new javax.swing.JLabel();
        tfAid = new javax.swing.JTextField();
        jLabel33 = new javax.swing.JLabel();
        tfAfornamn = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        tfAefternamn = new javax.swing.JTextField();
        jLabel35 = new javax.swing.JLabel();
        tfApers = new javax.swing.JTextField();
        tfAmail = new javax.swing.JTextField();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        tfAtelefon = new javax.swing.JTextField();
        jLabel38 = new javax.swing.JLabel();
        tfAadress = new javax.swing.JTextField();
        jLabel39 = new javax.swing.JLabel();
        tfAlosenord = new javax.swing.JTextField();
        jLabel40 = new javax.swing.JLabel();
        cbAbehorighet = new javax.swing.JComboBox();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel41 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jLabel32 = new javax.swing.JLabel();
        cbAIKonto = new javax.swing.JComboBox();
        jButton14 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        tfAlosen = new javax.swing.JTextField();
        jLabel45 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        tf1 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel46 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        cbRLand = new javax.swing.JComboBox();
        dateChooserCombo1 = new datechooser.beans.DateChooserCombo();
        dateChooserCombo2 = new datechooser.beans.DateChooserCombo();
        cbRUppdrag = new javax.swing.JComboBox();
        jSeparator5 = new javax.swing.JSeparator();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel47 = new javax.swing.JLabel();
        jLabel48 = new javax.swing.JLabel();
        jLabel49 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jlReseorder = new javax.swing.JList();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JSeparator();
        btnTabortRese = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        tfAnsok = new javax.swing.JTextField();
        lbAnsok = new javax.swing.JLabel();
        cbAnsok = new javax.swing.JComboBox();
        btAnsok = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jlRReseorderOk = new javax.swing.JList();
        jBOk = new javax.swing.JButton();
        jScrollPane8 = new javax.swing.JScrollPane();
        jlRStatusOk = new javax.swing.JList();
        jLabel15 = new javax.swing.JLabel();
        jLabel50 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jlRStatus = new javax.swing.JList();
        jScrollPane10 = new javax.swing.JScrollPane();
        jlRForskottOk = new javax.swing.JList();
        jScrollPane11 = new javax.swing.JScrollPane();
        jlRForskott = new javax.swing.JList();
        jScrollPane12 = new javax.swing.JScrollPane();
        jlRReseorder = new javax.swing.JList();
        jButton20 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jLabel51 = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        jLabel54 = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane13 = new javax.swing.JScrollPane();
        jlEjGodRapport = new javax.swing.JList();
        jScrollPane14 = new javax.swing.JScrollPane();
        jlEjGodForskott = new javax.swing.JList();
        jScrollPane15 = new javax.swing.JScrollPane();
        jlEjGodReseorder = new javax.swing.JList();
        jLabel55 = new javax.swing.JLabel();
        jLabel56 = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        jSeparator10 = new javax.swing.JSeparator();
        jSeparator11 = new javax.swing.JSeparator();
        jScrollPane16 = new javax.swing.JScrollPane();
        textAInfo = new javax.swing.JTextArea();
        jSeparator12 = new javax.swing.JSeparator();
        jButton22 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jLabel58 = new javax.swing.JLabel();
        jScrollPane17 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel59 = new javax.swing.JLabel();
        jLabel60 = new javax.swing.JLabel();
        jScrollPane18 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jLabel61 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        lblInloggad = new javax.swing.JLabel();
        lblKent = new javax.swing.JLabel();
        popupLaggTillLand = new javax.swing.JFrame();
        jPanel7 = new javax.swing.JPanel();
        cbPopupValjLand = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        dcPopupStart = new datechooser.beans.DateChooserCombo();
        jLabel21 = new javax.swing.JLabel();
        dcPopupSlut = new datechooser.beans.DateChooserCombo();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        tfPopupJobbadeDagar = new javax.swing.JTextField();
        btnPopupLaggTill = new javax.swing.JButton();
        tfAvdrag1 = new javax.swing.JTextField();
        tfAvdrag2 = new javax.swing.JTextField();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        checkboxAvdrag = new javax.swing.JCheckBox();
        jLabel44 = new javax.swing.JLabel();
        bgFardMedel = new javax.swing.ButtonGroup();
        popupLaggTillUppdrag = new javax.swing.JFrame();
        jPanel6 = new javax.swing.JPanel();
        cbPopUpKonto = new javax.swing.JComboBox();
        tfPopUpAndel = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jDialog1 = new javax.swing.JDialog();
        tfMail = new javax.swing.JTextField();
        tfLosenord = new javax.swing.JPasswordField();
        jLabel19 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jDialog2 = new javax.swing.JDialog();
        jLabel62 = new javax.swing.JLabel();
        jScrollPane19 = new javax.swing.JScrollPane();
        tfNekad = new javax.swing.JTextArea();
        jButton24 = new javax.swing.JButton();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        tfRInkl.setEditable(false);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(scrumprojekt.ScrumprojektApp.class).getContext().getResourceMap(ScrumprojektView.class);
        tfRInkl.setText(resourceMap.getString("tfRInkl.text")); // NOI18N
        tfRInkl.setName("tfRInkl"); // NOI18N
        jPanel1.add(tfRInkl, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, 100, -1));

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));

        tfRExkl.setEditable(false);
        tfRExkl.setText(resourceMap.getString("tfRExkl.text")); // NOI18N
        tfRExkl.setName("tfRExkl"); // NOI18N
        jPanel1.add(tfRExkl, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 100, -1));

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, -1, -1));

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 450, 100, 30));

        tfROvrigt.setText(resourceMap.getString("tfROvrigt.text")); // NOI18N
        tfROvrigt.setName("tfROvrigt"); // NOI18N
        jPanel1.add(tfROvrigt, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 340, 170, 20));

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 320, -1, -1));

        tfRKM.setEditable(false);
        tfRKM.setText(resourceMap.getString("tfRKM.text")); // NOI18N
        tfRKM.setName("tfRKM"); // NOI18N
        jPanel1.add(tfRKM, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, 100, -1));

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N
        jPanel1.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        taRKommentar.setColumns(20);
        taRKommentar.setLineWrap(true);
        taRKommentar.setRows(5);
        taRKommentar.setName("taRKommentar"); // NOI18N
        jScrollPane3.setViewportView(taRKommentar);

        jPanel1.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 380, 170, 100));

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N
        jPanel1.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 360, -1, 20));

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 440, -1, -1));

        cbRapportEdit.setName("cbRapportEdit"); // NOI18N
        jPanel1.add(cbRapportEdit, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 460, 110, -1));

        jButton7.setText(resourceMap.getString("jButton7.text")); // NOI18N
        jButton7.setName("jButton7"); // NOI18N
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 460, 70, 20));

        jButton8.setText(resourceMap.getString("jButton8.text")); // NOI18N
        jButton8.setName("jButton8"); // NOI18N
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton8, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 120, -1, -1));

        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N
        jPanel1.add(jCheckBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 420, -1, -1));

        btnRapportLaggTillKonto.setText(resourceMap.getString("btnRapportLaggTillKonto.text")); // NOI18N
        btnRapportLaggTillKonto.setName("btnRapportLaggTillKonto"); // NOI18N
        btnRapportLaggTillKonto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });
        jPanel1.add(btnRapportLaggTillKonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 380, 120, 20));

        btnRapportLaggTillLand.setText(resourceMap.getString("btnRapportLaggTillLand.text")); // NOI18N
        btnRapportLaggTillLand.setName("btnRapportLaggTillLand"); // NOI18N
        btnRapportLaggTillLand.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRapportLaggTillLandActionPerformed(evt);
            }
        });
        jPanel1.add(btnRapportLaggTillLand, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 240, 100, 20));

        dCCRapportStart.setLocale(new java.util.Locale("sv", "", ""));
        jPanel1.add(dCCRapportStart, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, 170, -1));

        dCCRapportSlut.setLocale(new java.util.Locale("sv", "", ""));
        jPanel1.add(dCCRapportSlut, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 280, 170, -1));

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, -1, -1));

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 260, -1, 20));

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jlSkapaRapport.setName("jlSkapaRapport"); // NOI18N
        jScrollPane1.setViewportView(jlSkapaRapport);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 150, 250, 80));

        bgFardMedel.add(rbROvriga);
        rbROvriga.setText(resourceMap.getString("rbROvriga.text")); // NOI18N
        rbROvriga.setName("rbROvriga"); // NOI18N
        rbROvriga.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbROvrigaActionPerformed(evt);
            }
        });
        jPanel1.add(rbROvriga, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, -1));

        bgFardMedel.add(rbRPrivatbil);
        rbRPrivatbil.setText(resourceMap.getString("rbRPrivatbil.text")); // NOI18N
        rbRPrivatbil.setName("rbRPrivatbil"); // NOI18N
        rbRPrivatbil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbRPrivatbilActionPerformed(evt);
            }
        });
        jPanel1.add(rbRPrivatbil, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, -1, -1));

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jlRUppdrag.setName("jlRUppdrag"); // NOI18N
        jScrollPane2.setViewportView(jlRUppdrag);

        jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 290, 250, 80));

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jlRFardsatt.setName("jlRFardsatt"); // NOI18N
        jScrollPane4.setViewportView(jlRFardsatt);

        jPanel1.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 30, 250, 80));

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N
        jPanel1.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 10, -1, -1));

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N
        jPanel1.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 130, -1, -1));

        jLabel26.setText(resourceMap.getString("jLabel26.text")); // NOI18N
        jLabel26.setName("jLabel26"); // NOI18N
        jPanel1.add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 270, -1, -1));

        jButton12.setText(resourceMap.getString("jButton12.text")); // NOI18N
        jButton12.setName("jButton12"); // NOI18N
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton12, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 380, -1, -1));

        jButton13.setText(resourceMap.getString("jButton13.text")); // NOI18N
        jButton13.setName("jButton13"); // NOI18N
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton13, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 240, -1, -1));

        btnRLaggTillFardsatt.setText(resourceMap.getString("btnRLaggTillFardsatt.text")); // NOI18N
        btnRLaggTillFardsatt.setName("btnRLaggTillFardsatt"); // NOI18N
        btnRLaggTillFardsatt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRLaggTillFardsattActionPerformed(evt);
            }
        });
        jPanel1.add(btnRLaggTillFardsatt, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 110, -1));

        rapportTfCount.setEditable(false);
        rapportTfCount.setText(resourceMap.getString("rapportTfCount.text")); // NOI18N
        rapportTfCount.setName("rapportTfCount"); // NOI18N
        jPanel1.add(rapportTfCount, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 410, 40, -1));

        lblAnstid.setText(resourceMap.getString("lblAnstid.text")); // NOI18N
        lblAnstid.setName("lblAnstid"); // NOI18N
        jPanel1.add(lblAnstid, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 150, 20, -1));

        lblLogin.setText(resourceMap.getString("lblLogin.text")); // NOI18N
        lblLogin.setName("lblLogin"); // NOI18N
        jPanel1.add(lblLogin, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 180, 30, -1));

        btnRSpara.setText(resourceMap.getString("btnRSpara.text")); // NOI18N
        btnRSpara.setName("btnRSpara"); // NOI18N
        btnRSpara.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRSparaActionPerformed(evt);
            }
        });
        jPanel1.add(btnRSpara, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 430, 70, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        cbRaAnstalld.setName("cbRaAnstalld"); // NOI18N
        cbRaAnstalld.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbRaAnstalldActionPerformed(evt);
            }
        });
        jPanel3.add(cbRaAnstalld, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 140, -1));

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        jPanel3.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        jPanel3.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, -1, -1));

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        jlRaRapporter.setName("jlRaRapporter"); // NOI18N
        jScrollPane6.setViewportView(jlRaRapporter);

        jPanel3.add(jScrollPane6, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 210, 140, 190));

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N
        jPanel3.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 190, -1, -1));

        jButton9.setText(resourceMap.getString("jButton9.text")); // NOI18N
        jButton9.setName("jButton9"); // NOI18N
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 420, -1, -1));

        jSeparator8.setName("jSeparator8"); // NOI18N
        jPanel3.add(jSeparator8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, 590, 10));

        jSeparator9.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator9.setName("jSeparator9"); // NOI18N
        jPanel3.add(jSeparator9, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 150, 20, 320));

        jLabel12.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N
        jPanel3.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 160, -1, -1));

        jLabel13.setFont(resourceMap.getFont("jLabel13.font")); // NOI18N
        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N
        jPanel3.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 160, -1, -1));

        buttonGroup1.add(jRadioManad);
        jRadioManad.setText(resourceMap.getString("jRadioManad.text")); // NOI18N
        jRadioManad.setName("jRadioManad"); // NOI18N
        jRadioManad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioManadActionPerformed(evt);
            }
        });
        jPanel3.add(jRadioManad, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 210, -1, -1));

        buttonGroup1.add(jRadioKvartal);
        jRadioKvartal.setText(resourceMap.getString("jRadioKvartal.text")); // NOI18N
        jRadioKvartal.setName("jRadioKvartal"); // NOI18N
        jPanel3.add(jRadioKvartal, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 240, -1, -1));

        buttonGroup1.add(jRadioAr);
        jRadioAr.setText(resourceMap.getString("jRadioAr.text")); // NOI18N
        jRadioAr.setName("jRadioAr"); // NOI18N
        jPanel3.add(jRadioAr, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 270, -1, -1));

        jButton17.setText(resourceMap.getString("jButton17.text")); // NOI18N
        jButton17.setName("jButton17"); // NOI18N
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton17, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 310, -1, -1));

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N
        jPanel3.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 50, -1, -1));

        lblRapDatum.setFont(resourceMap.getFont("lblRapDatum.font")); // NOI18N
        lblRapDatum.setText(resourceMap.getString("lblRapDatum.text")); // NOI18N
        lblRapDatum.setName("lblRapDatum"); // NOI18N
        jPanel3.add(lblRapDatum, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 70, 80, -1));

        jButton18.setText(resourceMap.getString("jButton18.text")); // NOI18N
        jButton18.setName("jButton18"); // NOI18N
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton18, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 100, -1, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel16.setFont(resourceMap.getFont("jLabel16.font")); // NOI18N
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N
        jPanel5.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 0, 130, 30));

        tfANamn.setText(resourceMap.getString("tfANamn.text")); // NOI18N
        tfANamn.setName("tfANamn"); // NOI18N
        jPanel5.add(tfANamn, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, 139, -1));

        jButton10.setText(resourceMap.getString("jButton10.text")); // NOI18N
        jButton10.setName("jButton10"); // NOI18N
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, -1, -1));

        tfAKonto.setText(resourceMap.getString("tfAKonto.text")); // NOI18N
        tfAKonto.setName("tfAKonto"); // NOI18N
        jPanel5.add(tfAKonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, 80, -1));

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N
        jPanel5.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, -1, -1));

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N
        jPanel5.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 90, -1, -1));

        jButton11.setText(resourceMap.getString("jButton11.text")); // NOI18N
        jButton11.setName("jButton11"); // NOI18N
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton11, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 80, -1, -1));

        cbAkonto.setName("cbAkonto"); // NOI18N
        jPanel5.add(cbAkonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 40, 140, -1));

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator1.setName("jSeparator1"); // NOI18N
        jPanel5.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 10, 10, 480));

        jLabel31.setFont(resourceMap.getFont("jLabel31.font")); // NOI18N
        jLabel31.setText(resourceMap.getString("jLabel31.text")); // NOI18N
        jLabel31.setName("jLabel31"); // NOI18N
        jPanel5.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 0, 160, 30));

        tfAid.setEditable(false);
        tfAid.setText(resourceMap.getString("tfAid.text")); // NOI18N
        tfAid.setName("tfAid"); // NOI18N
        jPanel5.add(tfAid, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 450, 40, -1));

        jLabel33.setText(resourceMap.getString("jLabel33.text")); // NOI18N
        jLabel33.setName("jLabel33"); // NOI18N
        jPanel5.add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 40, -1, -1));

        tfAfornamn.setText(resourceMap.getString("tfAfornamn.text")); // NOI18N
        tfAfornamn.setName("tfAfornamn"); // NOI18N
        jPanel5.add(tfAfornamn, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 60, 130, -1));

        jLabel34.setText(resourceMap.getString("jLabel34.text")); // NOI18N
        jLabel34.setName("jLabel34"); // NOI18N
        jPanel5.add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 90, -1, -1));

        tfAefternamn.setText(resourceMap.getString("tfAefternamn.text")); // NOI18N
        tfAefternamn.setName("tfAefternamn"); // NOI18N
        jPanel5.add(tfAefternamn, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 110, 130, -1));

        jLabel35.setText(resourceMap.getString("jLabel35.text")); // NOI18N
        jLabel35.setName("jLabel35"); // NOI18N
        jPanel5.add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 140, -1, -1));

        tfApers.setText(resourceMap.getString("tfApers.text")); // NOI18N
        tfApers.setName("tfApers"); // NOI18N
        jPanel5.add(tfApers, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 160, 130, -1));

        tfAmail.setText(resourceMap.getString("tfAmail.text")); // NOI18N
        tfAmail.setName("tfAmail"); // NOI18N
        jPanel5.add(tfAmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 210, 130, -1));

        jLabel36.setText(resourceMap.getString("jLabel36.text")); // NOI18N
        jLabel36.setName("jLabel36"); // NOI18N
        jPanel5.add(jLabel36, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 190, -1, -1));

        jLabel37.setText(resourceMap.getString("jLabel37.text")); // NOI18N
        jLabel37.setName("jLabel37"); // NOI18N
        jPanel5.add(jLabel37, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 240, -1, -1));

        tfAtelefon.setText(resourceMap.getString("tfAtelefon.text")); // NOI18N
        tfAtelefon.setName("tfAtelefon"); // NOI18N
        jPanel5.add(tfAtelefon, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 260, 130, -1));

        jLabel38.setText(resourceMap.getString("jLabel38.text")); // NOI18N
        jLabel38.setName("jLabel38"); // NOI18N
        jPanel5.add(jLabel38, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 290, -1, -1));

        tfAadress.setText(resourceMap.getString("tfAadress.text")); // NOI18N
        tfAadress.setName("tfAadress"); // NOI18N
        jPanel5.add(tfAadress, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 310, 130, -1));

        jLabel39.setText(resourceMap.getString("jLabel39.text")); // NOI18N
        jLabel39.setName("jLabel39"); // NOI18N
        jPanel5.add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 340, -1, -1));

        tfAlosenord.setText(resourceMap.getString("tfAlosenord.text")); // NOI18N
        tfAlosenord.setName("tfAlosenord"); // NOI18N
        jPanel5.add(tfAlosenord, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 360, 130, -1));

        jLabel40.setText(resourceMap.getString("jLabel40.text")); // NOI18N
        jLabel40.setName("jLabel40"); // NOI18N
        jPanel5.add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 390, -1, -1));

        cbAbehorighet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Konsult", "Chef", "Administratör" }));
        cbAbehorighet.setName("cbAbehorighet"); // NOI18N
        jPanel5.add(cbAbehorighet, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 410, 130, -1));

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator2.setName("jSeparator2"); // NOI18N
        jPanel5.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 10, 10, 480));

        jLabel41.setFont(resourceMap.getFont("jLabel41.font")); // NOI18N
        jLabel41.setText(resourceMap.getString("jLabel41.text")); // NOI18N
        jLabel41.setName("jLabel41"); // NOI18N
        jPanel5.add(jLabel41, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 10, -1, -1));

        jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 460, -1, -1));

        jLabel32.setFont(resourceMap.getFont("jLabel32.font")); // NOI18N
        jLabel32.setText(resourceMap.getString("jLabel32.text")); // NOI18N
        jLabel32.setName("jLabel32"); // NOI18N
        jPanel5.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 180, -1, -1));

        cbAIKonto.setName("cbAIKonto"); // NOI18N
        jPanel5.add(cbAIKonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 210, 140, -1));

        jButton14.setText(resourceMap.getString("jButton14.text")); // NOI18N
        jButton14.setName("jButton14"); // NOI18N
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed1(evt);
            }
        });
        jPanel5.add(jButton14, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 290, 80, -1));

        jSeparator3.setName("jSeparator3"); // NOI18N
        jPanel5.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 170, 190, 10));

        tfAlosen.setText(resourceMap.getString("tfAlosen.text")); // NOI18N
        tfAlosen.setName("tfAlosen"); // NOI18N
        jPanel5.add(tfAlosen, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 260, 140, -1));

        jLabel45.setText(resourceMap.getString("jLabel45.text")); // NOI18N
        jLabel45.setName("jLabel45"); // NOI18N
        jPanel5.add(jLabel45, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 240, -1, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel5.TabConstraints.tabTitle"), jPanel5); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        tf1.setName("tf1"); // NOI18N

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton19.setText(resourceMap.getString("jButton19.text")); // NOI18N
        jButton19.setName("jButton19"); // NOI18N
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(110, 110, 110)
                        .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jButton3))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(203, 203, 203)
                        .addComponent(jButton19)))
                .addContainerGap(365, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3))
                .addGap(30, 30, 30)
                .addComponent(jButton19)
                .addContainerGap(365, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        jPanel8.setName("jPanel8"); // NOI18N
        jPanel8.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel46.setFont(resourceMap.getFont("jLabel46.font")); // NOI18N
        jLabel46.setText(resourceMap.getString("jLabel46.text")); // NOI18N
        jLabel46.setName("jLabel46"); // NOI18N
        jPanel8.add(jLabel46, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 30, -1, -1));

        jSeparator4.setName("jSeparator4"); // NOI18N
        jPanel8.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 590, 10));

        cbRLand.setName("cbRLand"); // NOI18N
        jPanel8.add(cbRLand, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 150, 130, -1));

        dateChooserCombo1.setLocale(new java.util.Locale("sv", "", ""));
        jPanel8.add(dateChooserCombo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 150, -1, -1));

        dateChooserCombo2.setLocale(new java.util.Locale("sv", "", ""));
        jPanel8.add(dateChooserCombo2, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 200, -1, -1));

        cbRUppdrag.setName("cbRUppdrag"); // NOI18N
        jPanel8.add(cbRUppdrag, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 150, 160, -1));

        jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator5.setName("jSeparator5"); // NOI18N
        jPanel8.add(jSeparator5, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 140, 10, 80));

        jSeparator6.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator6.setName("jSeparator6"); // NOI18N
        jPanel8.add(jSeparator6, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 140, 10, 80));

        jLabel47.setText(resourceMap.getString("jLabel47.text")); // NOI18N
        jLabel47.setName("jLabel47"); // NOI18N
        jPanel8.add(jLabel47, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 110, -1, -1));

        jLabel48.setText(resourceMap.getString("jLabel48.text")); // NOI18N
        jLabel48.setName("jLabel48"); // NOI18N
        jPanel8.add(jLabel48, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 110, -1, -1));

        jLabel49.setText(resourceMap.getString("jLabel49.text")); // NOI18N
        jLabel49.setName("jLabel49"); // NOI18N
        jPanel8.add(jLabel49, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 110, -1, -1));

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        jlReseorder.setName("jlReseorder"); // NOI18N
        jScrollPane5.setViewportView(jlReseorder);

        jPanel8.add(jScrollPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 270, 210, 170));

        jButton15.setText(resourceMap.getString("jButton15.text")); // NOI18N
        jButton15.setName("jButton15"); // NOI18N
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });
        jPanel8.add(jButton15, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 220, 70, -1));

        jButton16.setText(resourceMap.getString("jButton16.text")); // NOI18N
        jButton16.setName("jButton16"); // NOI18N
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });
        jPanel8.add(jButton16, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 450, -1, -1));

        jSeparator7.setName("jSeparator7"); // NOI18N
        jPanel8.add(jSeparator7, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 258, 540, -1));

        btnTabortRese.setText(resourceMap.getString("btnTabortRese.text")); // NOI18N
        btnTabortRese.setName("btnTabortRese"); // NOI18N
        btnTabortRese.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTabortReseActionPerformed(evt);
            }
        });
        jPanel8.add(btnTabortRese, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 450, -1, -1));

        jTabbedPane1.addTab("Reseorder", jPanel8);

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        tfAnsok.setText(resourceMap.getString("tfAnsok.text")); // NOI18N
        tfAnsok.setName("tfAnsok"); // NOI18N
        jPanel4.add(tfAnsok, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, 110, -1));

        lbAnsok.setText(resourceMap.getString("lbAnsok.text")); // NOI18N
        lbAnsok.setName("lbAnsok"); // NOI18N
        jPanel4.add(lbAnsok, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 100, 110, -1));

        cbAnsok.setName("cbAnsok"); // NOI18N
        jPanel4.add(cbAnsok, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 110, -1));

        btAnsok.setText(resourceMap.getString("btAnsok.text")); // NOI18N
        btAnsok.setName("btAnsok"); // NOI18N
        btAnsok.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btAnsokMouseClicked(evt);
            }
        });
        jPanel4.add(btAnsok, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 160, -1, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N

        jPanel9.setName("jPanel9"); // NOI18N
        jPanel9.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jScrollPane7.setName("jScrollPane7"); // NOI18N

        jlRReseorderOk.setName("jlRReseorderOk"); // NOI18N
        jScrollPane7.setViewportView(jlRReseorderOk);

        jPanel9.add(jScrollPane7, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 280, 150, 130));

        jBOk.setText(resourceMap.getString("jBOk.text")); // NOI18N
        jBOk.setName("jBOk"); // NOI18N
        jBOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBOkActionPerformed(evt);
            }
        });
        jPanel9.add(jBOk, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 190, -1, -1));

        jScrollPane8.setName("jScrollPane8"); // NOI18N

        jlRStatusOk.setFocusable(false);
        jlRStatusOk.setName("jlRStatusOk"); // NOI18N
        jScrollPane8.setViewportView(jlRStatusOk);

        jPanel9.add(jScrollPane8, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 280, 150, -1));

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N
        jPanel9.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, -1, -1));

        jLabel50.setText(resourceMap.getString("jLabel50.text")); // NOI18N
        jLabel50.setName("jLabel50"); // NOI18N
        jPanel9.add(jLabel50, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, -1, -1));

        jScrollPane9.setName("jScrollPane9"); // NOI18N

        jlRStatus.setName("jlRStatus"); // NOI18N
        jScrollPane9.setViewportView(jlRStatus);

        jPanel9.add(jScrollPane9, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 50, 150, 130));

        jScrollPane10.setName("jScrollPane10"); // NOI18N

        jlRForskottOk.setName("jlRForskottOk"); // NOI18N
        jScrollPane10.setViewportView(jlRForskottOk);

        jPanel9.add(jScrollPane10, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 280, 220, 130));

        jScrollPane11.setName("jScrollPane11"); // NOI18N

        jlRForskott.setName("jlRForskott"); // NOI18N
        jScrollPane11.setViewportView(jlRForskott);

        jPanel9.add(jScrollPane11, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 50, 220, 130));

        jScrollPane12.setName("jScrollPane12"); // NOI18N

        jlRReseorder.setName("jlRReseorder"); // NOI18N
        jScrollPane12.setViewportView(jlRReseorder);

        jPanel9.add(jScrollPane12, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 50, 150, 130));

        jButton20.setText(resourceMap.getString("jButton19.text")); // NOI18N
        jButton20.setName("jButton19"); // NOI18N
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });
        jPanel9.add(jButton20, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 190, -1, -1));

        jButton21.setText(resourceMap.getString("jButton20.text")); // NOI18N
        jButton21.setName("jButton20"); // NOI18N
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });
        jPanel9.add(jButton21, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 190, -1, -1));

        jLabel51.setText(resourceMap.getString("jLabel51.text")); // NOI18N
        jLabel51.setName("jLabel51"); // NOI18N
        jPanel9.add(jLabel51, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 30, -1, -1));

        jLabel52.setText(resourceMap.getString("jLabel52.text")); // NOI18N
        jLabel52.setName("jLabel52"); // NOI18N
        jPanel9.add(jLabel52, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 30, -1, -1));

        jLabel53.setText(resourceMap.getString("jLabel53.text")); // NOI18N
        jLabel53.setName("jLabel53"); // NOI18N
        jPanel9.add(jLabel53, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 260, -1, -1));

        jLabel54.setText(resourceMap.getString("jLabel54.text")); // NOI18N
        jLabel54.setName("jLabel54"); // NOI18N
        jPanel9.add(jLabel54, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 260, -1, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel9.TabConstraints.tabTitle"), jPanel9); // NOI18N

        jPanel10.setName("jPanel10"); // NOI18N
        jPanel10.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jScrollPane13.setName("jScrollPane13"); // NOI18N

        jlEjGodRapport.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jlEjGodRapport.setName("jlEjGodRapport"); // NOI18N
        jlEjGodRapport.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jlEjGodRapportValueChanged(evt);
            }
        });
        jScrollPane13.setViewportView(jlEjGodRapport);

        jPanel10.add(jScrollPane13, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 170, 90));

        jScrollPane14.setName("jScrollPane14"); // NOI18N

        jlEjGodForskott.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jlEjGodForskott.setName("jlEjGodForskott"); // NOI18N
        jlEjGodForskott.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jlEjGodForskottValueChanged(evt);
            }
        });
        jScrollPane14.setViewportView(jlEjGodForskott);

        jPanel10.add(jScrollPane14, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 200, 270, 90));

        jScrollPane15.setName("jScrollPane15"); // NOI18N

        jlEjGodReseorder.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jlEjGodReseorder.setName("jlEjGodReseorder"); // NOI18N
        jlEjGodReseorder.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jlEjGodReseorderValueChanged(evt);
            }
        });
        jScrollPane15.setViewportView(jlEjGodReseorder);

        jPanel10.add(jScrollPane15, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 370, 170, 90));

        jLabel55.setFont(resourceMap.getFont("jLabel55.font")); // NOI18N
        jLabel55.setText(resourceMap.getString("jLabel55.text")); // NOI18N
        jLabel55.setName("jLabel55"); // NOI18N
        jPanel10.add(jLabel55, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, -1, -1));

        jLabel56.setFont(resourceMap.getFont("jLabel56.font")); // NOI18N
        jLabel56.setText(resourceMap.getString("jLabel56.text")); // NOI18N
        jLabel56.setName("jLabel56"); // NOI18N
        jPanel10.add(jLabel56, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 180, -1, -1));

        jLabel57.setFont(resourceMap.getFont("jLabel57.font")); // NOI18N
        jLabel57.setText(resourceMap.getString("jLabel57.text")); // NOI18N
        jLabel57.setName("jLabel57"); // NOI18N
        jPanel10.add(jLabel57, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 350, -1, -1));

        jSeparator10.setName("jSeparator10"); // NOI18N
        jPanel10.add(jSeparator10, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 170, 290, 10));

        jSeparator11.setName("jSeparator11"); // NOI18N
        jPanel10.add(jSeparator11, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 330, 290, 10));

        jScrollPane16.setName("jScrollPane16"); // NOI18N

        textAInfo.setColumns(20);
        textAInfo.setEditable(false);
        textAInfo.setFont(resourceMap.getFont("textAInfo.font")); // NOI18N
        textAInfo.setLineWrap(true);
        textAInfo.setRows(5);
        textAInfo.setEnabled(false);
        textAInfo.setName("textAInfo"); // NOI18N
        jScrollPane16.setViewportView(textAInfo);

        jPanel10.add(jScrollPane16, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 40, 260, 390));

        jSeparator12.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator12.setName("jSeparator12"); // NOI18N
        jPanel10.add(jSeparator12, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 30, 10, 460));

        jButton22.setText(resourceMap.getString("jButton22.text")); // NOI18N
        jButton22.setName("jButton22"); // NOI18N
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });
        jPanel10.add(jButton22, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 440, 80, -1));

        jButton23.setText(resourceMap.getString("jButton23.text")); // NOI18N
        jButton23.setName("jButton23"); // NOI18N
        jButton23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton23ActionPerformed(evt);
            }
        });
        jPanel10.add(jButton23, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 440, 80, -1));

        jLabel58.setText(resourceMap.getString("jLabel58.text")); // NOI18N
        jLabel58.setName("jLabel58"); // NOI18N
        jPanel10.add(jLabel58, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 20, 20, -1));

        jScrollPane17.setName("jScrollPane17"); // NOI18N

        jList1.setEnabled(false);
        jList1.setName("jList1"); // NOI18N
        jScrollPane17.setViewportView(jList1);

        jPanel10.add(jScrollPane17, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 40, 100, 90));

        jLabel59.setFont(resourceMap.getFont("jLabel59.font")); // NOI18N
        jLabel59.setText(resourceMap.getString("jLabel59.text")); // NOI18N
        jLabel59.setName("jLabel59"); // NOI18N
        jPanel10.add(jLabel59, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 20, -1, -1));

        jLabel60.setFont(resourceMap.getFont("jLabel60.font")); // NOI18N
        jLabel60.setText(resourceMap.getString("jLabel60.text")); // NOI18N
        jLabel60.setName("jLabel60"); // NOI18N
        jPanel10.add(jLabel60, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 350, -1, -1));

        jScrollPane18.setName("jScrollPane18"); // NOI18N

        jList3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jList3.setEnabled(false);
        jList3.setName("jList3"); // NOI18N
        jScrollPane18.setViewportView(jList3);

        jPanel10.add(jScrollPane18, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 370, 100, 90));

        jLabel61.setFont(resourceMap.getFont("jLabel61.font")); // NOI18N
        jLabel61.setText(resourceMap.getString("jLabel61.text")); // NOI18N
        jLabel61.setName("jLabel61"); // NOI18N
        jPanel10.add(jLabel61, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 20, -1, -1));

        jTabbedPane1.addTab(resourceMap.getString("jPanel10.TabConstraints.tabTitle"), jPanel10); // NOI18N

        mainPanel.add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 680, 520));

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(scrumprojekt.ScrumprojektApp.class).getContext().getActionMap(ScrumprojektView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
        statusPanel.add(statusPanelSeparator, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 620, -1));

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N
        statusPanel.add(statusMessageLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 8, -1, -1));

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
        statusPanel.add(statusAnimationLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 8, -1, -1));

        progressBar.setName("progressBar"); // NOI18N
        statusPanel.add(progressBar, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 8, -1, -1));

        lblInloggad.setFont(resourceMap.getFont("lblInloggad.font")); // NOI18N
        lblInloggad.setText(resourceMap.getString("lblInloggad.text")); // NOI18N
        lblInloggad.setName("lblInloggad"); // NOI18N
        statusPanel.add(lblInloggad, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, -1, 30));

        lblKent.setFont(resourceMap.getFont("lblKent.font")); // NOI18N
        lblKent.setText(resourceMap.getString("lblKent.text")); // NOI18N
        lblKent.setName("lblKent"); // NOI18N
        statusPanel.add(lblKent, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 5, 230, 20));

        popupLaggTillLand.setMinimumSize(new java.awt.Dimension(300, 400));
        popupLaggTillLand.setName("popupLaggTillLand"); // NOI18N
        popupLaggTillLand.setResizable(false);
        popupLaggTillLand.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel7.setName("jPanel6"); // NOI18N
        jPanel7.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        cbPopupValjLand.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tyskland" }));
        cbPopupValjLand.setName("cbPopupValjLand"); // NOI18N
        cbPopupValjLand.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbPopupValjLandItemStateChanged(evt);
            }
        });
        jPanel7.add(cbPopupValjLand, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 20, 150, -1));

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N
        jPanel7.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, 20));

        dcPopupStart.setNothingAllowed(false);
        dcPopupStart.setLocale(new java.util.Locale("sv", "", ""));
        jPanel7.add(dcPopupStart, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 60, -1, -1));

        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N
        jPanel7.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1, 20));

        dcPopupSlut.setLocale(new java.util.Locale("sv", "", ""));
        jPanel7.add(dcPopupSlut, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 100, -1, -1));

        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N
        jPanel7.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, 20));

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N
        jPanel7.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, 20));

        tfPopupJobbadeDagar.setName("tfPopupJobbadeDagar"); // NOI18N
        jPanel7.add(tfPopupJobbadeDagar, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 140, 150, -1));

        popupLaggTillLand.getContentPane().add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 285, 170));

        btnPopupLaggTill.setText(resourceMap.getString("btnPopupLaggTill.text")); // NOI18N
        btnPopupLaggTill.setName("btnPopupLaggTill"); // NOI18N
        btnPopupLaggTill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPopupLaggTillActionPerformed(evt);
            }
        });
        popupLaggTillLand.getContentPane().add(btnPopupLaggTill, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 310, -1, -1));

        tfAvdrag1.setEditable(false);
        tfAvdrag1.setText(resourceMap.getString("tfAvdrag1.text")); // NOI18N
        tfAvdrag1.setName("tfAvdrag1"); // NOI18N
        popupLaggTillLand.getContentPane().add(tfAvdrag1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 240, 150, -1));

        tfAvdrag2.setEditable(false);
        tfAvdrag2.setText(resourceMap.getString("tfAvdrag2.text")); // NOI18N
        tfAvdrag2.setName("tfAvdrag2"); // NOI18N
        popupLaggTillLand.getContentPane().add(tfAvdrag2, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 270, 150, -1));

        jLabel42.setText(resourceMap.getString("jLabel42.text")); // NOI18N
        jLabel42.setName("jLabel42"); // NOI18N
        popupLaggTillLand.getContentPane().add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, -1, 20));

        jLabel43.setText(resourceMap.getString("jLabel43.text")); // NOI18N
        jLabel43.setName("jLabel43"); // NOI18N
        popupLaggTillLand.getContentPane().add(jLabel43, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, -1, 20));

        checkboxAvdrag.setText(resourceMap.getString("checkboxAvdrag.text")); // NOI18N
        checkboxAvdrag.setName("checkboxAvdrag"); // NOI18N
        checkboxAvdrag.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkboxAvdragActionPerformed(evt);
            }
        });
        popupLaggTillLand.getContentPane().add(checkboxAvdrag, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, -1, -1));

        jLabel44.setText(resourceMap.getString("jLabel44.text")); // NOI18N
        jLabel44.setName("jLabel44"); // NOI18N
        popupLaggTillLand.getContentPane().add(jLabel44, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 220, -1, -1));

        popupLaggTillUppdrag.setMinimumSize(new java.awt.Dimension(300, 200));
        popupLaggTillUppdrag.setName("popupLaggTillUppdrag"); // NOI18N
        popupLaggTillUppdrag.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        cbPopUpKonto.setName("cbPopUpKonto"); // NOI18N
        jPanel6.add(cbPopUpKonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, 140, -1));

        tfPopUpAndel.setText(resourceMap.getString("tfPopUpAndel.text")); // NOI18N
        tfPopUpAndel.setName("tfPopUpAndel"); // NOI18N
        jPanel6.add(tfPopUpAndel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 70, 130, -1));

        jLabel27.setText(resourceMap.getString("jLabel27.text")); // NOI18N
        jLabel27.setName("jLabel27"); // NOI18N
        jPanel6.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, -1, 20));

        jLabel28.setText(resourceMap.getString("jLabel28.text")); // NOI18N
        jLabel28.setName("jLabel28"); // NOI18N
        jPanel6.add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, -1, 20));

        jLabel29.setText(resourceMap.getString("jLabel29.text")); // NOI18N
        jLabel29.setName("jLabel29"); // NOI18N
        jPanel6.add(jLabel29, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 70, 20, 20));

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 120, -1, -1));

        popupLaggTillUppdrag.getContentPane().add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 290, 160));

        jDialog1.setAlwaysOnTop(true);
        jDialog1.setName("jDialog1"); // NOI18N
        jDialog1.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        tfMail.setText(resourceMap.getString("tfMail.text")); // NOI18N
        tfMail.setName("tfMail"); // NOI18N
        jDialog1.getContentPane().add(tfMail, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 120, 90, -1));

        tfLosenord.setText(resourceMap.getString("tfLosenord.text")); // NOI18N
        tfLosenord.setName("tfLosenord"); // NOI18N
        jDialog1.getContentPane().add(tfLosenord, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 190, 90, -1));

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N
        jDialog1.getContentPane().add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 170, -1, -1));

        jLabel30.setText(resourceMap.getString("jLabel30.text")); // NOI18N
        jLabel30.setName("jLabel30"); // NOI18N
        jDialog1.getContentPane().add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 100, -1, -1));

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jDialog1.getContentPane().add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 240, -1, -1));

        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setName("jButton5"); // NOI18N
        jDialog1.getContentPane().add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 240, -1, -1));

        jDialog2.setName("jDialog2"); // NOI18N
        jDialog2.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel62.setFont(resourceMap.getFont("jLabel62.font")); // NOI18N
        jLabel62.setText(resourceMap.getString("jLabel62.text")); // NOI18N
        jLabel62.setName("jLabel62"); // NOI18N
        jDialog2.getContentPane().add(jLabel62, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, -1, -1));

        jScrollPane19.setName("jScrollPane19"); // NOI18N

        tfNekad.setColumns(20);
        tfNekad.setLineWrap(true);
        tfNekad.setRows(5);
        tfNekad.setName("tfNekad"); // NOI18N
        jScrollPane19.setViewportView(tfNekad);

        jDialog2.getContentPane().add(jScrollPane19, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 60, 190, 110));

        jButton24.setText(resourceMap.getString("jButton24.text")); // NOI18N
        jButton24.setName("jButton24"); // NOI18N
        jButton24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton24ActionPerformed(evt);
            }
        });
        jDialog2.getContentPane().add(jButton24, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 180, -1, -1));

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void btnRapportLaggTillLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRapportLaggTillLandActionPerformed

        cbPopup = new DefaultComboBoxModel();
        cbPopupValjLand.setModel(cbPopup);
        ArrayList<HashMap<String, String>> lander = new ArrayList<HashMap<String, String>>();
        String query = "Select landid, landnamn, traktamente from LAND";


        try {
            lander = db.fetchRows(query);

            for (HashMap<String, String> land : lander) {
                Land landet = new Land(
                        Integer.parseInt(land.get("landid")),
                        land.get("landnamn"),
                        Integer.parseInt(land.get("traktamente")));
                
                cbPopup.addElement(landet);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
        }

        popupLaggTillLand.setVisible(true);     }//GEN-LAST:event_btnRapportLaggTillLandActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            String hej = db.fetchSingle("select fornamn from anstalld where anstalldid = 1");
            tf1.setText(hej);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
        }
    }//GEN-LAST:event_jButton3ActionPerformed

private void cbPopupValjLandItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbPopupValjLandItemStateChanged
    // TODO add your handling code here:

    int i = cbPopupValjLand.getSelectedIndex();

    Land lan = (Land) cbPopup.getElementAt(i);
}//GEN-LAST:event_cbPopupValjLandItemStateChanged

    private void btnPopupLaggTillActionPerformed(java.awt.event.ActionEvent evt) {
        if(Validering.validFalt(tfPopupJobbadeDagar) && Validering.validSiffror(tfPopupJobbadeDagar) && Validering.validSiffror(tfAvdrag1) && Validering.validSiffror(tfAvdrag2))
                {
        
        jlSkapaRapport.setModel(jlRapport);
        int i = cbPopupValjLand.getSelectedIndex();
        Land lan = (Land) cbPopup.getElementAt(i);
        String start = dcPopupStart.getText();
        String slut = dcPopupSlut.getText();
        int antaldagar = Integer.parseInt(tfPopupJobbadeDagar.getText());
        int id = Integer.parseInt(rapportTfCount.getText());
        int tot = lan.getTraktamente() * antaldagar;

        int avdrag = 0;

        if (checkboxAvdrag.isSelected() == true) {

            int frukost = 0;
            int lunchmiddag = 0;

            if (!tfAvdrag1.getText().equals("")) {
                frukost = Integer.parseInt(tfAvdrag1.getText());
            }
            if (!tfAvdrag2.getText().equals("")) {
                lunchmiddag = Integer.parseInt(tfAvdrag2.getText());
            }

            int totfrukost = frukost * 44;
            int totlunchmiddag = lunchmiddag * 77;

            avdrag = totfrukost + totlunchmiddag;

            tot = tot - avdrag;
        }

              
                
        RapportLand RL = new RapportLand(start, slut, antaldagar, id, lan.getLandId(), tot, lan.getLandNamn());
        
        boolean finnsDaer = false;
        
        for(int in = 0; in < jlRapport.getSize(); in++){
            
            RapportLand land = (RapportLand) jlRapport.getElementAt(in);
            
            if(RL.getLandId() == land.getLandId()){
            finnsDaer = true;
            }
            }
        
            if(finnsDaer){
            JOptionPane.showMessageDialog(null, "Detta land finns redan i listan.");
            }
            else{
                
                
                    
                jlRapport.addElement(RL);
            
                popupLaggTillLand.setVisible(false);
                tfPopupJobbadeDagar.setText(null);
                checkboxAvdrag.setSelected(false);
                tfAvdrag1.setEditable(false);
                tfAvdrag2.setEditable(false);

                tfAvdrag1.setText(null);
                tfAvdrag2.setText(null);
            
        
          

    }
            }
    }
private void rbROvrigaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbROvrigaActionPerformed
    tfRKM.setEditable(false);
    tfRInkl.setEditable(true);
    tfRExkl.setEditable(true);
  
}//GEN-LAST:event_rbROvrigaActionPerformed

private void rbRPrivatbilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbRPrivatbilActionPerformed
    tfRKM.setEditable(true);
    tfRInkl.setEditable(false);
    tfRExkl.setEditable(false);
   
}//GEN-LAST:event_rbRPrivatbilActionPerformed

private void btnRLaggTillFardsattActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRLaggTillFardsattActionPerformed

    jlRFardsatt.setModel(jlRapport2);

    int val = 0;
    int km = 0;
    double summainkl = 0;
    double summaexkl = 0;
    int rapportid = Integer.parseInt(rapportTfCount.getText());

    if (rbRPrivatbil.isSelected() && Validering.validFalt(tfRKM) && Validering.validSiffror(tfRKM)) {
        
        km = Integer.parseInt(tfRKM.getText());
        val = 0;
        summainkl = km * 1.85;
        summaexkl = summainkl * 0.80;

        //  DecimalFormat twoDForm = new DecimalFormat("#,##");
        //       String inkl = twoDForm.format(summainkl);
        //       String exkl = twoDForm.format(summaexkl);

        Fardrapport rapport = new Fardrapport(val, rapportid, summainkl, summaexkl);

        jlRapport2.addElement(rapport);

        tfRKM.setText(null);
        
    } if (rbROvriga.isSelected() && Validering.validFalt(tfRInkl)  && Validering.validFalt(tfRExkl) && Validering.validSiffror(tfRInkl) && Validering.validSiffror(tfRExkl)) {
        val = 1;
        summainkl = Double.parseDouble(tfRInkl.getText());
        summaexkl = Double.parseDouble(tfRExkl.getText());

        //DecimalFormat twoDForm = new DecimalFormat("#,##");
        //       String inkl = twoDForm.format(summainkl);
        //       String exkl = twoDForm.format(summaexkl);

        Fardrapport rapport = new Fardrapport(val, rapportid, summainkl, summaexkl);

        jlRapport2.addElement(rapport);

        
        tfRInkl.setText(null);
        tfRExkl.setText(null);
    } 
    
}//GEN-LAST:event_btnRLaggTillFardsattActionPerformed

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
    if (jlRapport2.isEmpty()) {
    } else {
        int index = jlRFardsatt.getSelectedIndex();

        jlRapport2.removeElementAt(index);
    }
}//GEN-LAST:event_jButton8ActionPerformed

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
    if (jlRapport.isEmpty()) {
    } else {
        int index = jlSkapaRapport.getSelectedIndex();

        jlRapport.removeElementAt(index);
    }
}//GEN-LAST:event_jButton13ActionPerformed

private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
// TODO add your handling code here:
    popupLaggTillUppdrag.setVisible(true);
}//GEN-LAST:event_jButton14ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    if(Validering.validFalt(tfPopUpAndel)&& Validering.validSiffror(tfPopUpAndel)){
    
    jlRUppdrag.setModel(jlRapport3);

    int index = cbPopUpKonto.getSelectedIndex();

    Konto konto = (Konto) cbPopUpKonto.getItemAt(index);
    String rapportid = rapportTfCount.getText();
    int andel = Integer.parseInt(tfPopUpAndel.getText());

    Kontorapport kr = new Kontorapport(konto.getUppdragsNamn(), konto.getKontoNr(), Integer.parseInt(rapportid), andel);

    
    
            boolean finnsDaer = false;
        
            for(int in = 0; in < jlRapport3.getSize(); in++){
            
            Kontorapport kontor = (Kontorapport) jlRapport3.getElementAt(in);
            
            if(kr.getKontoNr() == kontor.getKontoNr()){
            finnsDaer = true;
            }
            }
        
            if(finnsDaer){
            JOptionPane.showMessageDialog(null, "Detta konto är redan valt för debitering.");
            }
            else{
                
                
                jlRapport3.addElement(kr);
                tfPopUpAndel.setText(null);
                popupLaggTillUppdrag.setVisible(false);
            
        
          

    }
    }
    
    
    
}//GEN-LAST:event_jButton2ActionPerformed

private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
    if (jlRapport3.isEmpty()) {
    } else {
        int index = jlRUppdrag.getSelectedIndex();
        jlRapport3.removeElementAt(index);
    }
}//GEN-LAST:event_jButton12ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    setRapportCount();
    
    String startdatum = dCCRapportStart.getText();
    String slutdatum = dCCRapportSlut.getText();
    String eu = tfROvrigt.getText();
    String ok = taRKommentar.getText();
    String rapportid = rapportTfCount.getText();
    String anstalldid = lblAnstid.getText();
    String kvitton;
    String godkand = "Nej";
    String godkandav = "Ej godkänd än";
    double totalsummainkl = 0;
    double totalsummaexkl = 0;

    String totalinklS = Double.toString(totalsummainkl);
    String totalexklS = Double.toString(totalsummaexkl);

    //kolla om extra utgifter är tom
    if (tfROvrigt.getText().equals("")) {
        eu = "0";
    }
    //slut
    //kolla checkbox
    if (jCheckBox1.isSelected()) {
        kvitton = "Ja";
    } else {
        kvitton = "Nej";
    }
    //slut
    // Hämta summor färdsätt
    for (int i = 0; i < jlRapport2.getSize(); i++) {
        Fardrapport fard = (Fardrapport) jlRapport2.getElementAt(i);
        totalsummainkl = totalsummainkl + fard.getInkl();

        totalsummaexkl = totalsummaexkl + fard.getExkl();
    }
    //slut
    //Hämta summor traktamente
    for (int i = 0; i < jlRapport.getSize(); i++) {
        RapportLand land = (RapportLand) jlRapport.getElementAt(i);
        totalsummainkl = totalsummainkl + land.getRapportLandTrakt();
    }
    //slut 
    
    //Kolla om vi överstiger 100% i andel JL'en
    
    int totalProcent = 0;
    
    for (int i = 0; i < jlRapport3.getSize(); i++) {

        Kontorapport kontorapport = (Kontorapport) jlRapport3.getElementAt(i);
        totalProcent = totalProcent + kontorapport.getAndel();
        
    }
    //SLUT
   
    
    //insert rapport!
    
    String query1 = "Insert into rapport (rapportid, anstalldid, summainklmoms, summaexklmoms, kvitto, godkand, godkandav, startdatum, slutdatum, extrakostnader, kommentar)"
            + "values ('" + rapportid + "' , '" + anstalldid + "' , '" + Double.toString(totalsummainkl) + "' , '" + Double.toString(totalsummaexkl) + "' , '" + kvitton + "' , '" + godkand + "' , '" + godkandav + "' , '" + startdatum + "' , '" + slutdatum + "' , '" + eu + "' , '" + ok + "')";
    
    if(Validering.validSiffror(tfROvrigt)){
        if(totalProcent <100 ||  totalProcent >100){
            JOptionPane.showMessageDialog(null, "Du har angett en total procentandel mindre eller mer än 100% på dina uppdrag, se över detta!");
        }
        else{
        
    try {
        db.insert(query1);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.getMessage()+"rapport");
    }
    
  
    //Hämta färdsätt
    for (int i = 0; i < jlRapport2.getSize(); i++) {

        Fardrapport fardsatt = (Fardrapport) jlRapport2.getElementAt(i);

        String query2 = "insert into fardrapport (fardsattid, rapportid, summainklmoms, summaexklmoms) VALUES ('" + fardsatt.getFardsattId() + "' , '" + fardsatt.getRapportId() + "' , '" + fardsatt.getInkl() + "' , '" + fardsatt.getExkl() + "')";
        try {
            db.insert(query2);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage()+"fard");
        }
    }
    //Hämta land
    for (int i = 0; i < jlRapport.getSize(); i++) {

        RapportLand rapportland = (RapportLand) jlRapport.getElementAt(i);

        String query3 = "insert into rapportland (rapportid, landid, landstart, landslut, landdagar, rapportLandTraktamente) VALUES ('" + rapportland.getRapportId() + "' , '" + rapportland.getLandId() + "' , '" + rapportland.getLandStart() + "' , '" + rapportland.getLandSlut() + "' , '" + rapportland.getLandDagar() + "' , '" + rapportland.getRapportLandTrakt() + "')";
        try {
            db.insert(query3);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage()+"land");
        }
    }

    //Hämta uppdrag
    for (int i = 0; i < jlRapport3.getSize(); i++) {

        Kontorapport kontorapport = (Kontorapport) jlRapport3.getElementAt(i);

        String query4 = "insert into kontorapport (kontonr, rapportid, andel) VALUES ('" + kontorapport.getKontoNr() + "' , '" + kontorapport.getRapportId() + "' , '" + kontorapport.getAndel() + "')";

        try {
            db.insert(query4);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage()+"konto");
        }
    }

      mail me = new mail();
    try {
        me.postMail();
    } catch (MessagingException ex) {
        Logger.getLogger(ScrumprojektView.class.getName()).log(Level.SEVERE, null, ex);
    }
        
        tfROvrigt.setText(null);
        taRKommentar.setText(null);
        jlRapport.removeAllElements();
        jlRapport2.removeAllElements();
        jlRapport3.removeAllElements();
        setRapportCount();
    }

    
    
    } 
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    mainPanel.setVisible(true);
    jDialog1.setVisible(false);
    valideraLogin();
    login();
    fyllRapportStatus();
    fyllRapportStatusOk();
    fyllForskottStatus();
    fyllReseorderStatus();
    fyllForskottStatusOk();
    fyllReseorderStatusOk();
    fyllCbEdit();
    InloggadJustNu();
    fyllEjGodRapport();
    fyllEjGodReseorder();
    fyllEjGodForskott();
}//GEN-LAST:event_jButton4ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        String kontonamn = tfANamn.getText();
        String kontonummer = tfAKonto.getText();

        if (Validering.validFalt2(tfANamn, tfAKonto) && Validering.validSiffror(tfAKonto)) {
            try {
                db.insert("insert into konto (kontonr, uppdragsnamn) values('" + kontonummer + "', '" + kontonamn + "')");

                Konto konto = new Konto(Integer.parseInt(kontonummer), kontonamn);
                cbPopUpKonto.addItem(konto);

                tfANamn.setText(null);
                tfAKonto.setText(null);
                cbRUppdrag.removeAllItems();
                fyllReseUppdragcb();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, null);
            }
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        int i = cbAkonto.getSelectedIndex();

        Anstalld anstalld = (Anstalld) cbAkonto.getItemAt(i);

        try {
            db.update("update anstalld set losenord = null where anstalldid = '" + anstalld.getAnstalldid() + "'");
            cbAkonto.removeAllItems();
            fyllAnvkontoCb();
            cbAIKonto.removeAllItems();
            fyllIckeAnvkontoCb();
            JOptionPane.showMessageDialog(null, "Konto inaktiverat för vidare inloggning!");

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }//GEN-LAST:event_jButton11ActionPerformed

private void checkboxAvdragActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxAvdragActionPerformed
    if (checkboxAvdrag.isSelected() == true) {
        tfAvdrag1.setEditable(true);
        tfAvdrag2.setEditable(true);

    } else {
        tfAvdrag1.setEditable(false);
        tfAvdrag2.setEditable(false);

        tfAvdrag1.setText(null);
        tfAvdrag2.setText(null);
    }
}//GEN-LAST:event_checkboxAvdragActionPerformed

    private void jButton14ActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed1
        int i = cbAIKonto.getSelectedIndex();

        Anstalld anstalld = (Anstalld) cbAIKonto.getItemAt(i);

        String losen = tfAlosen.getText();
        
        if(Validering.validFalt(tfAlosen)){
        
        

        try {
            db.update("update anstalld set losenord = '" + losen + "' where anstalldid = '" + anstalld.getAnstalldid() + "'");
            cbAIKonto.removeAllItems();
            fyllIckeAnvkontoCb();
            JOptionPane.showMessageDialog(null, "Konto aktiverat för inloggning igen!");
            cbAkonto.removeAllItems();
            fyllAnvkontoCb();
            tfAlosen.setText(null);

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
        }
    }//GEN-LAST:event_jButton14ActionPerformed1

        private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
            jlReseorder.setModel(jlReseorderrapport);

            int orderid = 0;
            int anstalldid = 0;
            String land = cbRLand.getSelectedItem().toString();
            String datumstart = dateChooserCombo1.getText();
            String datumslut = dateChooserCombo2.getText();
            String konto = cbRUppdrag.getSelectedItem().toString();
            String godkand = "Nej";
            String kommentar = "";
            Reseorder reseorder = new Reseorder(orderid, anstalldid, land, datumstart, datumslut, konto, godkand, kommentar);

            jlReseorderrapport.addElement(reseorder);
    }//GEN-LAST:event_jButton15ActionPerformed

private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed

    String anstidd = lblAnstid.getText();
    int anstalldid = Integer.parseInt(anstidd);
    String land = cbRLand.getSelectedItem().toString();
    String datumstart = dateChooserCombo1.getText();
    String datumslut = dateChooserCombo2.getText();
    String konto = cbRUppdrag.getSelectedItem().toString();
    
    int size = jlReseorderrapport.size();
    int dsa = jlReseorder.getSelectedIndex();
    
    if(!(size == 0)){

    for (int i = 0; i < jlReseorderrapport.getSize(); i++) {

        Reseorder reseorder = (Reseorder) jlReseorderrapport.getElementAt(i);

        String query = "INSERT INTO reseorder ( anstalldid, land, datumstart, datumslut, kontonr, godkand, godkandav, kommentar) VALUES ('" + anstalldid + "', '" + reseorder.getLand() + "', '" + reseorder.getDatumstart() + "', '" + reseorder.getDatumslut() + "', '" + reseorder.getKonto() + "', 'Nej', '', '')";

        try {
            db.insert(query);
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
    jlReseorderrapport.clear();
    }
}//GEN-LAST:event_jButton16ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        String id = tfAid.getText();
        String fornamn = tfAfornamn.getText();
        String efternamn = tfAefternamn.getText();
        String persnr = tfApers.getText();
        String mail = tfAmail.getText();
        String tlf = tfAtelefon.getText();
        String adress = tfAadress.getText();
        String losen = tfAlosenord.getText();
        String beh;

        //Kolla vilken behörighet som är vald i comboboxen för att sedan göra om de till behörighetsskalan 1-3 i databasen//
        String behorigheten = cbAbehorighet.getSelectedItem().toString();

        if (behorigheten.equals("Konsult")) {
            beh = "3";
        } else if (behorigheten.equals("Chef")) {
            beh = "2";
        } else {
            beh = "1";
        }
        //SLUT//
        //hämta alla fält, kolla om dem är tomma och gör en insert i databasen om dom inte är de//

        boolean fylldaFalt = false;

        if (Validering.validFalt7(tfAfornamn, tfAefternamn, tfApers, tfAmail, tfAtelefon, tfAadress, tfAlosenord)) {

            fylldaFalt = true;

            if (fylldaFalt && Validering.validSiffror(tfApers) && Validering.validSiffror(tfAtelefon)) {

                try {
                    db.insert("insert into anstalld (anstalldid, fornamn, efternamn, personnummer, mail, telefon, adress, losenord, behorighet) "
                            + "values('" + id + "', '" + fornamn + "', '" + efternamn + "', '" + persnr + "', '" + mail + "', '" + tlf + "', '" + adress + "' , '" + losen + "', '" + beh + "')");

                    setAnvKontonCount();

                    //Töm alla fälten//
                    tfAfornamn.setText(null);
                    tfAefternamn.setText(null);
                    tfApers.setText(null);
                    tfAmail.setText(null);
                    tfAtelefon.setText(null);
                    tfAadress.setText(null);
                    tfAlosenord.setText(null);
                    //SLUT//
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
                }
            }
        }
    }//GEN-LAST:event_jButton6ActionPerformed

private void btAnsokMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btAnsokMouseClicked
    if (Validering.validFalt(tfAnsok) && Validering.validSiffror(tfAnsok)) {
        ansokForskott();
    }
}//GEN-LAST:event_btAnsokMouseClicked

    private void cbRaAnstalldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbRaAnstalldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbRaAnstalldActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed

        jlRaRapporter1.removeAllElements();

        jlRaRapporter.setModel(jlRaRapporter1);

        Anstalld anst = (Anstalld) cbRaAnstalld.getSelectedItem();

        String query = "select * from rapport where anstalldid = '" + anst.getAnstalldid() + "'";

        try {
            ArrayList<HashMap<String, String>> rapporter = db.fetchRows(query);

            for (HashMap<String, String> rapport : rapporter) {

                Rapport rap = new Rapport(rapport.get("startdatum"), rapport.get("datumslut"), Integer.parseInt(rapport.get("summainklmoms")), Integer.parseInt(rapport.get("summaexklmoms")), rapport.get("kvitto"), rapport.get("godkand"), rapport.get("godkandav"), Integer.parseInt(rapport.get("rapportid")), Integer.parseInt("0"), Integer.parseInt(rapport.get("anstalldid")), Integer.parseInt(rapport.get("extrakostnader")), rapport.get("kommentar"));
                jlRaRapporter1.addElement(rap);

            }


        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
        }
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        
        int size = jlRaRapporter1.size();
        
        if(!(size == 0)){
        Anstalld anst = (Anstalld) cbRaAnstalld.getSelectedItem();
        Rapport rap = (Rapport) jlRaRapporter1.getElementAt(jlRaRapporter.getSelectedIndex());

        String anstId = Integer.toString(anst.getAnstalldid());
        String startDat = rap.getStartDatum();

        sparaPdf(anstId, startDat);
        }


    }//GEN-LAST:event_jButton9ActionPerformed

    private void jRadioManadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioManadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioManadActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        Anstalld anst = (Anstalld) cbRaAnstalld.getSelectedItem();
        String date = lblRapDatum.getText();

        String manad1;
        String manad2;
        String manad3;


        if (jRadioManad.isSelected()) {

            sparaPdfSummeringManad(Integer.toString(anst.getAnstalldid()), date.substring(0, 7));
        } else if (jRadioKvartal.isSelected()) {

            String manad = date.substring(5, 7);
            String manad0 = date.substring(6, 7);
            String ar = date.substring(0, 4);


            if (manad.startsWith("01")) {
                manad1 = Integer.toString(Integer.parseInt(ar) - 1) + "-" + "11";
                manad2 = Integer.toString(Integer.parseInt(ar) - 1) + "-" + "12";
                manad3 = ar + "-" + "01";
            }
            if (manad.startsWith("02")) {
                manad1 = Integer.toString(Integer.parseInt(ar) - 1) + "-" + "12";
                manad2 = ar + "-" + "01";
                manad3 = ar + "-" + "02";
            }
            if (manad.startsWith("03")) {
                manad1 = ar + "-" + "01";
                manad2 = ar + "-" + "02";
                manad3 = ar + "-" + "03";
            } else {
                manad1 = ar + "-0" + manad0;
                manad2 = ar + "-0" + (Integer.parseInt(manad0) - 1);
                manad3 = ar + "-0" + (Integer.parseInt(manad0) - 2);
            }

            sparaPdfSummeringKvartal(Integer.toString(anst.getAnstalldid()), manad1, manad2, manad3);
        } else if (jRadioAr.isSelected()) {
            sparaPdfSummeringAr(Integer.toString(anst.getAnstalldid()), date.substring(0, 4));

        }
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jBOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBOkActionPerformed
        kollaRapport();
    }//GEN-LAST:event_jBOkActionPerformed

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    jlRapport2.clear(); 
     jlRapport.clear();
     jlRapport3.clear(); 
     jCheckBox1.setSelected(false);
     btnRSpara.setVisible(true);
     jButton1.setVisible(false);
    
     jlRFardsatt.setModel(jlRapport2);
     jlSkapaRapport.setModel(jlRapport);
     jlRUppdrag.setModel(jlRapport3);
     
    Rapport rapport = (Rapport) cbRapportEdit.getSelectedItem();

    int rapportId = rapport.getRapportid();


    if (rapport.getKvitto().equals("Ja")) {

        jCheckBox1.setSelected(true);
    }

    String query1 = "select * from fardrapport where rapportid = " + rapportId;
    String query2 = "select * from rapportland join land on rapportland.landid = land.landid where rapportland.rapportid = " + rapportId;
    String query3 = "select * from kontorapport join konto on kontorapport.kontonr = konto.kontonr where kontorapport.rapportid = " + rapportId;
    try {
        ArrayList<HashMap<String, String>> fardsatt = db.fetchRows(query1);
        ArrayList<HashMap<String, String>> landrapport = db.fetchRows(query2);
        ArrayList<HashMap<String, String>> uppdrag = db.fetchRows(query3);

        for (HashMap<String, String> fard : fardsatt) {

            Fardrapport rap = new Fardrapport(
                    Integer.parseInt(fard.get("fardsattid")),
                    Integer.parseInt(fard.get("rapportid")),
                    Double.parseDouble(fard.get("summainklmoms")),
                    Double.parseDouble(fard.get("summaexklmoms")));

            jlRapport2.addElement(rap);

        }

        for (HashMap<String, String> land : landrapport) {

            RapportLand lan = new RapportLand(
                    land.get("landstart"),
                    land.get("landslut"),
                    Integer.parseInt(land.get("landdagar")),
                    Integer.parseInt(land.get("rapportid")),
                    Integer.parseInt(land.get("landid")),
                    Integer.parseInt(land.get("rapportlandtraktamente")),
                    land.get("landnamn"));

            jlRapport.addElement(lan);

            for (HashMap<String, String> kon : uppdrag) {

                Kontorapport kont = new Kontorapport(
                        kon.get("uppdragsnamn"),
                        Integer.parseInt(kon.get("kontonr")),
                        Integer.parseInt(kon.get("rapportid")),
                        Integer.parseInt(kon.get("andel")));

                jlRapport3.addElement(kont);

            }

        }





    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
    }

    tfROvrigt.setText(Integer.toString(rapport.getExtraKostnader()));
    taRKommentar.setText(rapport.getKommentar());

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date;
    try {
        date = sdf.parse(rapport.getStartDatum());
        Calendar cal = Calendar.getInstance();

        cal.setTime(date);
        dCCRapportStart.setSelectedDate(cal);
    } catch (ParseException ex) {
        Logger.getLogger(ScrumprojektView.class.getName()).log(Level.SEVERE, null, ex);
    }

    Date date2;
    try {
        date2 = sdf.parse(rapport.getSlutDatum());
        Calendar cal = Calendar.getInstance();

        cal.setTime(date2);
        dCCRapportSlut.setSelectedDate(cal);
    } catch (ParseException ex) {
        Logger.getLogger(ScrumprojektView.class.getName()).log(Level.SEVERE, null, ex);
    }


}//GEN-LAST:event_jButton7ActionPerformed

private void btnRSparaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRSparaActionPerformed
    
  
    Rapport rapport = (Rapport) cbRapportEdit.getSelectedItem();

    int rapportId = rapport.getRapportid();


    String startdatum = dCCRapportStart.getText();
    String slutdatum = dCCRapportSlut.getText();
    String eu = tfROvrigt.getText();
    String ok = taRKommentar.getText();
    String rapportid = rapportTfCount.getText();
    String anstalldid = lblAnstid.getText();
    String kvitton;
    String godkand = "Nej";
    String godkandav = "Ej godkänd än";
    double totalsummainkl = 0;
    double totalsummaexkl = 0;

    String totalinklS = Double.toString(totalsummainkl);
    String totalexklS = Double.toString(totalsummaexkl);


    if (tfROvrigt.getText().equals("")) {
        eu = "0";
    }

    if (jCheckBox1.isSelected()) {
        kvitton = "Ja";
    } else {
        kvitton = "Nej";
    }

    for (int i = 0; i < jlRapport2.getSize(); i++) {
        Fardrapport fard = (Fardrapport) jlRapport2.getElementAt(i);
        totalsummainkl = totalsummainkl + fard.getInkl();

        totalsummaexkl = totalsummaexkl + fard.getExkl();
    }

    for (int i = 0; i < jlRapport.getSize(); i++) {
        RapportLand land = (RapportLand) jlRapport.getElementAt(i);
        totalsummainkl = totalsummainkl + land.getRapportLandTrakt();
    }
   
    //Kolla om vi överstiger 100% i andel JL'en
    
    int totalProcent = 0;
    
    for (int i = 0; i < jlRapport3.getSize(); i++) {

        Kontorapport kontorapport = (Kontorapport) jlRapport3.getElementAt(i);
        totalProcent = totalProcent + kontorapport.getAndel();
        
    }
    //SLUT

    //update rapport 
    //set  anstalldid='4', summainklmoms='1401', summaexklmoms='40', kvitto='Ja', godkand='Nej', godkandav='Ej godkänd än', startdatum= '2012-04-17', slutdatum='2012-04-22', extrakostnader='500', kommentar= 'tjo'
    //where rapportid = 1

    String query1 = "update rapport set summainklmoms='" + Double.toString(totalsummainkl) + "', summaexklmoms='" + Double.toString(totalsummaexkl) + "', kvitto='" + kvitton + "', godkand='" + godkand + "', "
            + "godkandav='" + godkandav + "', startdatum= '" + startdatum + "', slutdatum='" + slutdatum + "', extrakostnader='" + eu + "', kommentar= '" + ok + "' "
            + "where rapportid = '" + rapportId + "'";
    
    if(Validering.validSiffror(tfROvrigt)){
        if(totalProcent <100 ||  totalProcent >100){
            JOptionPane.showMessageDialog(null, "Du har angett en total procentandel mindre eller mer än 100% på dina uppdrag, se över detta!");
        }
        else{

    try {
        db.update(query1);
    } catch (InformatikException e) {
        JOptionPane.showMessageDialog(null, e.getMessage() + "updaterapport");
    }

    String query2 = "delete from fardrapport where rapportid ='" + rapportId + "'";
    String query3 = "delete from rapportland where rapportid ='" + rapportId + "'";
    String query4 = "delete from kontorapport where rapportid ='" + rapportId + "'";
    try {
        db.delete(query2);
        db.delete(query3);
        db.delete(query4);
    } catch (InformatikException e) {
        JOptionPane.showMessageDialog(null, e.getMessage() + "delete");
    }

    for (int i = 0; i < jlRapport2.getSize(); i++) {

        Fardrapport fardsatt = (Fardrapport) jlRapport2.getElementAt(i);

        String query5 = "insert into fardrapport (fardsattid, rapportid, summainklmoms, summaexklmoms) VALUES ('" + fardsatt.getFardsattId() + "' , '" + fardsatt.getRapportId() + "' , '" + fardsatt.getInkl() + "' , '" + fardsatt.getExkl() + "')";
        try {
            db.insert(query5);
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage() + "insertfardmedel");
        }
    }

    for (int i = 0; i < jlRapport.getSize(); i++) {

        RapportLand rapportland = (RapportLand) jlRapport.getElementAt(i);

        String query6 = "insert into rapportland (rapportid, landid, landstart, landslut, landdagar, rapportLandTraktamente) VALUES ('" + rapportland.getRapportId() + "' , '" + rapportland.getLandId() + "' , '" + rapportland.getLandStart() + "' , '" + rapportland.getLandSlut() + "' , '" + rapportland.getLandDagar() + "' , '" + rapportland.getRapportLandTrakt() + "')";
        try {
            db.insert(query6);
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage() + "insertland");
        }
    }


    for (int i = 0; i < jlRapport3.getSize(); i++) {

        Kontorapport kontorapport = (Kontorapport) jlRapport3.getElementAt(i);

        String query7 = "insert into kontorapport (kontonr, rapportid, andel) VALUES ('" + kontorapport.getKontoNr() + "' , '" + rapportId + "' , '" + kontorapport.getAndel() + "')";

        try {

            db.insert(query7);
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage() + "insertkonto");
        }
    }

    tfROvrigt.setText(null);
    taRKommentar.setText(null);
    jlRapport.removeAllElements();
    jlRapport2.removeAllElements();
    jlRapport3.removeAllElements();
    jCheckBox1.setSelected(false);
    jButton1.setVisible(true);
    btnRSpara.setVisible(false);
        }
    }
}//GEN-LAST:event_btnRSparaActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
       
    }//GEN-LAST:event_jButton19ActionPerformed

    private void btnTabortReseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTabortReseActionPerformed
        int dsa = -1;
        int size = jlReseorderrapport.size();
        dsa = jlReseorder.getSelectedIndex();
        
        if((size != 0 && dsa != -1)){
        jlReseorderrapport.removeElementAt(dsa);
        }
    }//GEN-LAST:event_btnTabortReseActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
        kollaForskott();
    }//GEN-LAST:event_jButton20ActionPerformed

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
        kollaReseorder();
    }//GEN-LAST:event_jButton21ActionPerformed

    private void jlEjGodRapportValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlEjGodRapportValueChanged
        
        int index = jlEjGodRapport.getSelectedIndex();
        String y = Integer.toString(index);
        
        jLabel13.setText(y);
        
        if(index == -1) {
            jList1.clearSelection();
            textAInfo.setText("--------------------------------\nVälj Rapport, Förskott eller en reseorder i listorna bredvid för godkännande\n--------------------------------");
        }else{
            jList1.setSelectedIndex(index);
            jlEjGodForskott.clearSelection();
            jlEjGodReseorder.clearSelection();
        }
        
        infoEjGodRapport();
    }//GEN-LAST:event_jlEjGodRapportValueChanged

    private void jlEjGodForskottValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlEjGodForskottValueChanged
        int index = jlEjGodForskott.getSelectedIndex();
        String y = Integer.toString(index);
        
        jLabel13.setText(y);
        
        if(index == -1) {
            textAInfo.setText("--------------------------------\nVälj Rapport, Förskott eller en reseorder i listorna bredvid för godkännande\n--------------------------------");
        }else{   
            jlEjGodReseorder.clearSelection();
            jlEjGodRapport.clearSelection();
        }
        
        infoEjGodForskott();
    }//GEN-LAST:event_jlEjGodForskottValueChanged

    private void jlEjGodReseorderValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlEjGodReseorderValueChanged
         
        int index = jlEjGodReseorder.getSelectedIndex();
        String y = Integer.toString(index);
        
        jLabel13.setText(y);
        
        if(index == -1) {
            jList3.clearSelection();
            textAInfo.setText("--------------------------------\nVälj Rapport, Förskott eller en reseorder i listorna bredvid för godkännande\n--------------------------------");
        }else{
            jList3.setSelectedIndex(index);   
            jlEjGodForskott.clearSelection();
            jlEjGodRapport.clearSelection();
        }
        infoEjGodReseorder();   
    }//GEN-LAST:event_jlEjGodReseorderValueChanged

    private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
        if(jlEjGodRapport.getSelectedIndex() >= 0){
            
            int index = jList1.getSelectedIndex();            
            Rapport rapp = (Rapport) jListTest.getElementAt(index);

            try {
                db.update("UPDATE rapport SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"
                        + "WHERE rapportid = '" + rapp.getRapportid() + "'");
                JOptionPane.showMessageDialog(null, "Rapport nekad");
                tfNekad.setText("");
                jDialog2.setVisible(false);
                jListTest.removeElementAt(index);
                jlEjGodRapportModel.removeElementAt(index);
            }
            catch (InformatikException e){
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        }
/////////////////////NEKA RESEORDRAR////////////////////////////////////////////////
        else if(jlEjGodReseorder.getSelectedIndex() >= 0){
            
            int index = jList3.getSelectedIndex();            
            Reseorder reseorder = (Reseorder) jListTest3.getElementAt(index);

            try {
                db.update("UPDATE reseorder SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"
                        + "WHERE orderid = '" + reseorder.getOrderid() + "'");
                JOptionPane.showMessageDialog(null, "Reseorder nekad");
                tfNekad.setText("");
                jDialog2.setVisible(false);
                jListTest3.removeElementAt(index);
                jlEjGodReseorderModel.removeElementAt(index);
            }
            catch (InformatikException e){
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        }
/////////////////////NEKA FÖRSKOTT////////////////////////////////////////////////
        else if(jlEjGodForskott.getSelectedIndex() >= 0){
            
            int index = jlEjGodForskott.getSelectedIndex();            
            Forskott forskott = (Forskott) jlEjGodForskottModel.getElementAt(index);

            try {
                db.update("UPDATE forskott SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"
                        + "WHERE forskottid = '" + forskott.getForskottId() + "'");
                JOptionPane.showMessageDialog(null, "Förskott nekat");
                tfNekad.setText("");
                jDialog2.setVisible(false);
                jlEjGodForskottModel.removeElementAt(index);
            }
            catch (InformatikException e){
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        }
        
        cbRapportEdit.removeAllItems();
        fyllCbEdit();
 /////////////////////NEKA RAPPORT////////////////////////////////////////////////                 if (jlEjGodRapport.getSelectedIndex() >= 0) {              int index = jList1.getSelectedIndex();             Rapport rapp = (Rapport) jListTest.getElementAt(index);              try {                 db.update("UPDATE rapport SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"                         + "WHERE rapportid = '" + rapp.getRapportid() + "'");                 JOptionPane.showMessageDialog(null, "Rapport nekad");                 tfNekad.setText("");                 jDialog2.setVisible(false);                 jListTest.removeElementAt(index);                 jlEjGodRapportModel.removeElementAt(index);             } catch (InformatikException e) {                 JOptionPane.showMessageDialog(null, e.getMessage());             }         } /////////////////////NEKA RESEORDRAR////////////////////////////////////////////////         else if (jlEjGodReseorder.getSelectedIndex() >= 0) {              int index = jList3.getSelectedIndex();             Reseorder reseorder = (Reseorder) jListTest3.getElementAt(index);              try {                 db.update("UPDATE reseorder SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"                         + "WHERE orderid = '" + reseorder.getOrderid() + "'");                 JOptionPane.showMessageDialog(null, "Reseorder nekad");                 tfNekad.setText("");                 jDialog2.setVisible(false);                 jListTest3.removeElementAt(index);                 jlEjGodReseorderModel.removeElementAt(index);             } catch (InformatikException e) {                 JOptionPane.showMessageDialog(null, e.getMessage());             }         } /////////////////////NEKA FÖRSKOTT////////////////////////////////////////////////         else if (jlEjGodForskott.getSelectedIndex() >= 0) {              int index = jlEjGodForskott.getSelectedIndex();             Forskott forskott = (Forskott) jlEjGodForskottModel.getElementAt(index);              try {                 db.update("UPDATE forskott SET kommentar = '" + tfNekad.getText() + "', godkand = 'ccc'"                         + "WHERE forskottid = '" + forskott.getForskottId() + "'");                 JOptionPane.showMessageDialog(null, "Förskott nekat");                 tfNekad.setText("");                 jDialog2.setVisible(false);                 jlEjGodForskottModel.removeElementAt(index);             } catch (InformatikException e) {                 JOptionPane.showMessageDialog(null, e.getMessage());             }         }     }//GEN-LAST:event_jButton24ActionPerformed
    }
        private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
        if(jlEjGodRapport.getSelectedIndex() >= 0){
        int index = jList1.getSelectedIndex();            
        Rapport rapp = (Rapport) jListTest.getElementAt(index);
        
        int rapportid = rapp.getRapportid();
        String anstid = lblAnstid.getText();
        
        try {
            db.update("UPDATE rapport SET godkand = 'Ja', godkandav = '" + anstid + "' "
                    + "WHERE rapportid = '" + rapportid + "'");
        }
        catch (InformatikException e){
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        
        //Vid godkännande rensas fält och objektet tas bort från listan.
        JOptionPane.showMessageDialog(null, "Rapport godkänd!");
        jlEjGodRapportModel.removeAllElements();
        jListTest.removeAllElements();
        textAInfo.setText("");
        fyllEjGodRapport();
        
        }else if(jlEjGodReseorder.getSelectedIndex() >= 0){
            int index = jList3.getSelectedIndex();            
            Reseorder reseorder = (Reseorder) jListTest3.getElementAt(index);

            int orderid = reseorder.getOrderid();
            String anstid = lblAnstid.getText();

                try {
                    db.update("UPDATE reseorder SET godkand = 'Ja', godkandav = '" + anstid + "' "
                            + "WHERE orderid = '" + orderid + "'");
                }
                catch (InformatikException e){
                    JOptionPane.showMessageDialog(null, e.getMessage());
                }

            //Vid godkännande rensas fält och objektet tas bort från listan.
            JOptionPane.showMessageDialog(null, "Reseordern godkänd!");
            jlEjGodReseorderModel.removeAllElements();
            jListTest3.removeAllElements();
            textAInfo.setText("");
            fyllEjGodReseorder();
        }
        
        else if(jlEjGodForskott.getSelectedIndex() >= 0){
            int index = jlEjGodForskott.getSelectedIndex();            
            Forskott forskott = (Forskott) jlEjGodForskottModel.getElementAt(index);

            int forskottid = forskott.getForskottId();
            String anstid = lblAnstid.getText();

                try {
                    db.update("UPDATE forskott SET godkand = 'Ja'"
                            + "WHERE forskottid = '" + forskottid + "'");
                }
                catch (InformatikException e){
                    JOptionPane.showMessageDialog(null, e.getMessage());
                }

            //Vid godkännande rensas fält och objektet tas bort från listan.
            JOptionPane.showMessageDialog(null, "Förskottet godkänt!");
            jlEjGodForskottModel.removeAllElements();
            textAInfo.setText("");
            fyllEjGodForskott();
        }
    }//GEN-LAST:event_jButton22ActionPerformed

    private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
        jDialog2.setSize(300, 250);
        jDialog2.setLocationRelativeTo(null);
        jDialog2.setVisible(true);
    }//GEN-LAST:event_jButton23ActionPerformed

    public void login() {
        String fornamn = "";
        String efternamn = "";
        String mail1 = tfMail.getText();
        String mail2 = null;
        char[] input1 = tfLosenord.getPassword();
        String input2 = "";
        ArrayList<HashMap<String, String>> anstallda = new ArrayList<HashMap<String, String>>();
        String query = "SELECT * FROM anstalld "
                + "WHERE mail = '" + mail1 + "'";

        try {
            anstallda = db.fetchRows(query);
            for (HashMap<String, String> anst : anstallda) {

                Anstalld anstalld = new Anstalld(
                        fornamn = anst.get("fornamn"),
                        efternamn = anst.get("efternamn"),
                        Integer.parseInt(anst.get("personnummer")),
                        mail2 = anst.get("mail"),
                        Integer.parseInt(anst.get("telefon")),
                        anst.get("adress"),
                        input2 = anst.get("losenord"),
                        behorighet = Integer.parseInt(anst.get("behorighet")),
                        anstid = Integer.parseInt(anst.get("anstalldid")));
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
        }

        char[] g = input2.toCharArray();

        if (mail1.equals(mail2) && (Arrays.equals(input1, g))) {

            String y = Integer.toString(anstid);
            String x = Integer.toString(behorighet);
            lblAnstid.setText(y);
            lblLogin.setText(x);
            String labelTexten = lblLogin.getText();

            if (labelTexten.equals("1")) {
                // jTabbedPane1.setEnabledAt(3, false);
            } else if (labelTexten.equals("3")) {
                jTabbedPane1.setEnabledAt(1, false);
                jTabbedPane1.setEnabledAt(3, false);
                jTabbedPane1.setEnabledAt(2, false);
            } else if (labelTexten.equals("2")) {
                jTabbedPane1.setEnabledAt(3, false);
            }

            //VÄlkomstruta
            JOptionPane.showMessageDialog(null, "Välkommen " + fornamn + " " + efternamn + ".");
        } else {
            JOptionPane.showMessageDialog(null, "Fel mail eller lösenord", "Fel!", JOptionPane.ERROR_MESSAGE);
            jDialog1.setVisible(true);
            mainPanel.setVisible(false);
        }
    }

    public void valideraLogin() {
        if (tfMail.getText().isEmpty() && tfLosenord == null) {
            JOptionPane.showMessageDialog(null, "Du måste fylla i mail och lösenord!", "Fel!", JOptionPane.ERROR_MESSAGE);
            jDialog1.setVisible(true);
            mainPanel.setVisible(false);
        }
    }

    public void doljKomponenterLogin() {
        mainPanel.setVisible(false);
        jDialog1.setVisible(true);
        jDialog1.setSize(400, 350);
        jDialog1.setLocationRelativeTo(null);
        popupLaggTillLand.setLocationRelativeTo(null);
    }

    public void reseorder() {
        ///////////////FYLLER LANDCOMBOBOXEN
        cbReseorderLand = new DefaultComboBoxModel();
        cbRLand.setModel(cbReseorderLand);
        ArrayList<HashMap<String, String>> rland = new ArrayList<HashMap<String, String>>();
        String query = "Select landid, landnamn, traktamente from LAND";

        try {
            rland = db.fetchRows(query);

            for (HashMap<String, String> land : rland) {
                Land landet = new Land(
                        Integer.parseInt(land.get("landid")),
                        land.get("landnamn"),
                        Integer.parseInt(land.get("traktamente")));

                cbReseorderLand.addElement(landet);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Något gick fel! Kontakta support!");
        }

        //Fyller uppdrags-listan med uppdrag
        fyllReseUppdragcb();
        ////////////////////////////////////////////////////
    }

    private void fyllReseUppdragcb() {
        try {
            ArrayList<HashMap<String, String>> uppdragsnamn = db.fetchRows("select * from konto");

            for (HashMap<String, String> uppdrag : uppdragsnamn) {
                Konto uppdraget = new Konto(Integer.parseInt(uppdrag.get("kontonr")), uppdrag.get("uppdragsnamn"));
                cbRUppdrag.addItem(uppdraget);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    private void fyllAnsokCb() {
        try {
            ArrayList<HashMap<String, String>> uppdragsnamn = db.fetchRows("select * from konto");

            for (HashMap<String, String> uppdrag : uppdragsnamn) {
                Konto uppdraget = new Konto(Integer.parseInt(uppdrag.get("kontonr")), uppdrag.get("uppdragsnamn"));
                cbAnsok.addItem(uppdraget);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, null);
        }
    }

    private void ansokForskott() {
        Konto konto = (Konto) cbAnsok.getItemAt(cbAnsok.getSelectedIndex());
        int kontoNr = konto.getKontoNr();
        int forskottSumma = Integer.parseInt(tfAnsok.getText());
        int anstalldId = Integer.parseInt(lblAnstid.getText());


        String queryForskott = "insert into forskott (forskottsumma, kontonr, anstalldid , godkand) "
                + "values (" + forskottSumma + "," + kontoNr + "," + anstalldId + ", 'Nej')";
        try {
            db.insert(queryForskott);
        } catch (InformatikException ex) {
            Logger.getLogger(ScrumprojektView.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            JOptionPane.showMessageDialog(null, "Förskotts förfrågan skickad!");
            tfAnsok.setText("");
        }
    }
    
    ///////////////////////////////GODKÄNNA TABBEN///////////////////////////
    
    
    private void fyllEjGodRapport(){
        
        jlEjGodRapport.setModel(jlEjGodRapportModel);
        jList1.setModel(jListTest);
        //String anv = lblAnstid.getText();
       // int anstalldid = Integer.parseInt(anv);
        
        
        try {
            ArrayList<HashMap<String, String>> ejGodRapport = db.fetchRows("SELECT * FROM rapport WHERE godkand = 'Nej' AND anstalldid NOT IN(SELECT anstalldid FROM anstalld WHERE anstalldid ='" + Integer.parseInt(lblAnstid.getText()) +"')");

            for (HashMap<String, String> ejGod : ejGodRapport) {
                Rapport rap = new Rapport(
                        ejGod.get("startdatum"), 
                        ejGod.get("slutdatum"), 
                        Integer.parseInt(ejGod.get("summainklmoms")), 
                        Integer.parseInt(ejGod.get("summaexklmoms")),
                        ejGod.get("kvitto"), 
                        ejGod.get("godkand"), 
                        ejGod.get("godkandav"), 
                        Integer.parseInt(ejGod.get("rapportid")), 
                        0, 
                        Integer.parseInt(ejGod.get("anstalldid")), 
                        Integer.parseInt(ejGod.get("extrakostnader")), 
                        ejGod.get("kommentar"));
                
                        HashMap<String, String> namnet = db.fetchRow("SELECT * FROM anstalld JOIN rapport ON anstalld.anstalldid = rapport.anstalldid where rapport.rapportid = '"+Integer.toString(rap.getRapportid())+"'"+" group by anstalld.anstalldid");
                            jlEjGodRapportModel.addElement("ID:" + namnet.get("anstalldid") + " " + namnet.get("fornamn") + " " + namnet.get("efternamn"));
                            jListTest.addElement(rap);
                }
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
    
    
    private void infoEjGodRapport(){
        
        int index = jList1.getSelectedIndex();
        
        if(index >= 0 && index < jListTest.size()){
            
        Rapport rapp = (Rapport) jListTest.getElementAt(index);
        int rapportid = rapp.getRapportid();
        int anstid = rapp.getAnstalldId();
        String fornamn = "";
        String efternamn = "";
        
        try{
            HashMap<String, String> namn = db.fetchRow("SELECT * FROM anstalld "
                   + "WHERE anstalldid = '"+Integer.toString(anstid)+"'");
            
            fornamn = namn.get("fornamn");
            efternamn = namn.get("efternamn");
            
        }catch (InformatikException e){
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        
        textAInfo.setText("AnställningsID:\n" + rapp.getAnstalldId() +  
                "\nNamn:\n" + fornamn + " " +efternamn +
                "\n------------------------------------" +
                "\nRapportID:\n" + rapp.getRapportid() +
                "\nGodkänd:\n" + rapp.getGodkand() +
                //"\nGodkänd av: " + " [INGEN ÄN]" +
                "\nStartdatum:\n" + rapp.getStartDatum() +
                "\nSlutdatum:\n" + rapp.getSlutDatum() +
                "\nSumma inkl. moms:\n" + rapp.getSumma() + ":-" + 
                "\nSumma exkl. moms:\n" + rapp.getSummaMoms() + ":-" + 
                "\nKvitto finnes:\n" + rapp.getKvitto() +
                "\nExtra kostnader:\n" + rapp.getExtraKostnader() + ":-" +
                "\n------------------------------------" +
                "\nKommentar:\n" + rapp.getKommentar());
        }
    }
    
    
    private void fyllEjGodReseorder(){
        
        jlEjGodReseorder.setModel(jlEjGodReseorderModel);
        jList3.setModel(jListTest3);
        try {
            ArrayList<HashMap<String, String>> ejGodReseorder = db.fetchRows("SELECT * FROM reseorder WHERE godkand = 'Nej' AND anstalldid NOT IN(SELECT anstalldid FROM anstalld WHERE anstalldid ='" + Integer.parseInt(lblAnstid.getText()) +"')");

            for (HashMap<String, String> ejGod : ejGodReseorder) {
                 Reseorder reseorder = new Reseorder(
                         Integer.parseInt(ejGod.get("orderid")), 
                         Integer.parseInt(ejGod.get("anstalldid")), 
                         ejGod.get("land"), 
                         ejGod.get("datumstart"), 
                         ejGod.get("datumslut"), 
                         ejGod.get("konto"), 
                         ejGod.get("godkand"),
                         ejGod.get("kommentar"));
                 
                         HashMap<String, String> namn1 = db.fetchRow("SELECT * FROM anstalld JOIN reseorder ON anstalld.anstalldid = reseorder.anstalldid where reseorder.orderid = '"+Integer.toString(reseorder.getOrderid())+"'"+" group by anstalld.anstalldid");

                jlEjGodReseorderModel.addElement("ID:" + namn1.get("anstalldid") + " " + namn1.get("fornamn") + " " + namn1.get("efternamn"));
                jListTest3.addElement(reseorder);
            }
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
    
    private void infoEjGodReseorder(){
        
        int index = jList3.getSelectedIndex();
        
        if(index >= 0 && index < jListTest3.size()){
            
        Reseorder reseord = (Reseorder) jListTest3.getElementAt(index);
        int orderid = reseord.getOrderid();
        int anstid = reseord.getAnstalldid();
        String fornamn = "";
        String efternamn = "";
        
        try{
            HashMap<String, String> namn = db.fetchRow("SELECT * FROM anstalld "
                   + "WHERE anstalldid = '"+Integer.toString(anstid)+"'");
            
            fornamn = namn.get("fornamn");
            efternamn = namn.get("efternamn");
            
        }catch (InformatikException e){
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        
        textAInfo.setText("AnställningsID:\n" + reseord.getAnstalldid() +  
                "\nNamn:\n" + fornamn + " " +efternamn +
                "\n------------------------------------" +
                "\nOrderID:\n" + reseord.getOrderid() +
                "\nGodkänd:\n" + reseord.getGodkand() +
                "\nStartdatum:\n" + reseord.getDatumstart() +
                "\nSlutdatum:\n" + reseord.getDatumslut() +
                "\nKonto:\n" + reseord.getKonto() +
                "\n------------------------------------" +
                "\nKommentar:\n HEJJEJEHEEHASASDASDASDASDASDSDASDASDASCASFASDASDASDASD");
        }
    }

        
    private void fyllEjGodForskott(){
        
        jlEjGodForskott.setModel(jlEjGodForskottModel);
        
        try {
            ArrayList<HashMap<String, String>> ejGodForskott1 = db.fetchRows("SELECT * FROM forskott WHERE godkand = 'Nej' AND anstalldid NOT IN(SELECT anstalldid FROM anstalld WHERE anstalldid ='" + lblAnstid.getText() +"')");

            for (HashMap<String, String> ejGod1 : ejGodForskott1) {
                 Forskott forskott = new Forskott(
                         Integer.parseInt(ejGod1.get("forskottid")), 
                         Integer.parseInt(ejGod1.get("forskottsumma")), 
                         Integer.parseInt(ejGod1.get("kontonr")), 
                         Integer.parseInt(ejGod1.get("anstalldid")),  
                         ejGod1.get("godkand"),
                         ejGod1.get("kommentar"));
                         
                            HashMap<String, String> namn2 = db.fetchRow("SELECT * FROM anstalld JOIN forskott ON anstalld.anstalldid = forskott.anstalldid where forskott.forskottid = '"+Integer.toString(forskott.getForskottId())+"'"+" group by anstalld.anstalldid");

                 
                //jlEjGodForskottModel.addElement("ID:" + namn2.get("anstalldid") + " " + namn2.get("fornamn") + " " + namn2.get("efternamn"));
                jlEjGodForskottModel.addElement(forskott);
            }
        } catch (InformatikException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        } 
    }      
    
    private void infoEjGodForskott(){
        
        int index = jlEjGodForskott.getSelectedIndex();
        
        if(index >= 0 && index < jlEjGodForskottModel.size()){
            
        Forskott forskott = (Forskott) jlEjGodForskottModel.getElementAt(index);
        int orderid = forskott.getForskottId();
        int anstid = forskott.getAnstalldId();
        String fornamn = "";
        String efternamn = "";
        
        try{
            HashMap<String, String> namn = db.fetchRow("SELECT * FROM anstalld "
                   + "WHERE anstalldid = '"+Integer.toString(anstid)+"'");
            
            fornamn = namn.get("fornamn");
            efternamn = namn.get("efternamn");
            
        }catch (InformatikException e){
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        
        textAInfo.setText("AnställningsID:\n" + forskott.getAnstalldId() +  
                "\nNamn:\n" + fornamn + " " +efternamn +
                "\n------------------------------------" +
                "\nOrderID:\n" + forskott.getForskottId() +
                "\nGodkänd:\n" + forskott.getGodkand() +
                "\nSumma:\n" + forskott.getForskottSumma() +
                "\nKontonr:\n" + forskott.getKontoNr() +
                "\n------------------------------------" +
                "\nKommentar:\n HEJJEJEHEEHASASDASDASDASDASDSDASDASDASCASFASDASDASDASD");
        }
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgFardMedel;
    private javax.swing.JButton btAnsok;
    private javax.swing.JButton btnPopupLaggTill;
    private javax.swing.JButton btnRLaggTillFardsatt;
    private javax.swing.JButton btnRSpara;
    private javax.swing.JButton btnRapportLaggTillKonto;
    private javax.swing.JButton btnRapportLaggTillLand;
    private javax.swing.JButton btnTabortRese;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbAIKonto;
    private javax.swing.JComboBox cbAbehorighet;
    private javax.swing.JComboBox cbAkonto;
    private javax.swing.JComboBox cbAnsok;
    private javax.swing.JComboBox cbPopUpKonto;
    private javax.swing.JComboBox cbPopupValjLand;
    private javax.swing.JComboBox cbRLand;
    private javax.swing.JComboBox cbRUppdrag;
    private javax.swing.JComboBox cbRaAnstalld;
    private javax.swing.JComboBox cbRapportEdit;
    private javax.swing.JCheckBox checkboxAvdrag;
    private datechooser.beans.DateChooserCombo dCCRapportSlut;
    private datechooser.beans.DateChooserCombo dCCRapportStart;
    private datechooser.beans.DateChooserCombo dateChooserCombo1;
    private datechooser.beans.DateChooserCombo dateChooserCombo2;
    private datechooser.beans.DateChooserCombo dcPopupSlut;
    private datechooser.beans.DateChooserCombo dcPopupStart;
    private javax.swing.JButton jBOk;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JDialog jDialog2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JList jList3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JRadioButton jRadioAr;
    private javax.swing.JRadioButton jRadioKvartal;
    private javax.swing.JRadioButton jRadioManad;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane15;
    private javax.swing.JScrollPane jScrollPane16;
    private javax.swing.JScrollPane jScrollPane17;
    private javax.swing.JScrollPane jScrollPane18;
    private javax.swing.JScrollPane jScrollPane19;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JList jlEjGodForskott;
    private javax.swing.JList jlEjGodRapport;
    private javax.swing.JList jlEjGodReseorder;
    private javax.swing.JList jlRFardsatt;
    private javax.swing.JList jlRForskott;
    private javax.swing.JList jlRForskottOk;
    private javax.swing.JList jlRReseorder;
    private javax.swing.JList jlRReseorderOk;
    private javax.swing.JList jlRStatus;
    private javax.swing.JList jlRStatusOk;
    private javax.swing.JList jlRUppdrag;
    private javax.swing.JList jlRaRapporter;
    private javax.swing.JList jlReseorder;
    private javax.swing.JList jlSkapaRapport;
    private javax.swing.JLabel lbAnsok;
    private javax.swing.JLabel lblAnstid;
    private javax.swing.JLabel lblInloggad;
    private javax.swing.JLabel lblKent;
    private javax.swing.JLabel lblLogin;
    private javax.swing.JLabel lblRapDatum;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JFrame popupLaggTillLand;
    private javax.swing.JFrame popupLaggTillUppdrag;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JTextField rapportTfCount;
    private javax.swing.JRadioButton rbROvriga;
    private javax.swing.JRadioButton rbRPrivatbil;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextArea taRKommentar;
    private javax.swing.JTextArea textAInfo;
    private javax.swing.JTextField tf1;
    private javax.swing.JTextField tfAKonto;
    private javax.swing.JTextField tfANamn;
    private javax.swing.JTextField tfAadress;
    private javax.swing.JTextField tfAefternamn;
    private javax.swing.JTextField tfAfornamn;
    private javax.swing.JTextField tfAid;
    private javax.swing.JTextField tfAlosen;
    private javax.swing.JTextField tfAlosenord;
    private javax.swing.JTextField tfAmail;
    private javax.swing.JTextField tfAnsok;
    private javax.swing.JTextField tfApers;
    private javax.swing.JTextField tfAtelefon;
    private javax.swing.JTextField tfAvdrag1;
    private javax.swing.JTextField tfAvdrag2;
    private javax.swing.JPasswordField tfLosenord;
    private javax.swing.JTextField tfMail;
    private javax.swing.JTextArea tfNekad;
    private javax.swing.JTextField tfPopUpAndel;
    private javax.swing.JTextField tfPopupJobbadeDagar;
    private javax.swing.JTextField tfRExkl;
    private javax.swing.JTextField tfRInkl;
    private javax.swing.JTextField tfRKM;
    private javax.swing.JTextField tfROvrigt;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private DefaultComboBoxModel cbPopup, cbReseorderLand;
    private DefaultListModel jlRapport, jlRapport2, jlRapport3, jlReseorderrapport, jlRaRapporter1, jlRapportStatus, jlRapportStatusOk, jlRReseorderStatus, jlRReseorderStatusOk, jlRForskottStatus, jlForskottStatusOk,jlEjGodRapportModel, jlEjGodReseorderModel, jlEjGodForskottModel, jListTest, jListTest3;
    private JDialog aboutBox;
    private dbklass db;
    private int behorighet = 0;
    private int anstid;
}
